public static < T > List < T > getParents ( DirectedGraph g , T n ) { List < IndexedEdge > incoming = new ArrayList ( g . incomingEdgesOf ( n ) ) ; Collections . sort ( incoming ) ; List < T > ret = new ArrayList ( ) ; for ( IndexedEdge e : incoming ) { ret . add ( ( T ) e . source ) ; } return ret ; }
Assumes edge contains an index