org.eclipse.osgi.internal.resolver
Class ComputeNodeOrder

java.lang.Object
  extended by org.eclipse.osgi.internal.resolver.ComputeNodeOrder

public class ComputeNodeOrder
extends Object

Borrowed from org.eclipse.core.internal.resources.ComputeProjectOrder to be used when computing the stop order. Implementation of a sort algorithm for computing the node order. This algorithm handles cycles in the node reference graph in a reasonable way.

Since:
3.0

Method Summary
static Object[][] computeNodeOrder(Object[] objects, Object[][] references)
          Sorts the given list of projects in a manner that honors the given project reference relationships.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

computeNodeOrder

public static Object[][] computeNodeOrder(Object[] objects,
                                          Object[][] references)
Sorts the given list of projects in a manner that honors the given project reference relationships. That is, if project A references project B, then the resulting order will list B before A if possible. For graphs that do not contain cycles, the result is the same as a conventional topological sort. For graphs containing cycles, the order is based on ordering the strongly connected components of the graph. This has the effect of keeping each knot of projects together without otherwise affecting the order of projects not involved in a cycle. For a graph G, the algorithm performs in O(|G|) space and time.

When there is an arbitrary choice, vertexes are ordered as supplied. Arranged projects in descending alphabetical order generally results in an order that builds "A" before "Z" when there are no other constraints.

Ref: Cormen, Leiserson, and Rivest Introduction to Algorithms, McGraw-Hill, 1990. The strongly-connected-components algorithm is in section 23.5.

Parameters:
objects - a list of projects (element type: IProject)
references - a list of project references [A,B] meaning that A references B (element type: IProject[])
Returns:
an object describing the resulting project order


Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.