Skip to content

Commit b66c86f

Browse files
committed
GraphUtils: add getLeafs method
1 parent 20ecc21 commit b66c86f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • src/main/java/org/mastodon/mamut/tomancak/lineage_registration

src/main/java/org/mastodon/mamut/tomancak/lineage_registration/GraphUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,13 @@ public static < V extends Vertex< E > & HasTimepoint, E extends Edge< V > > RefS
5252
graph.releaseRef( ref );
5353
}
5454
}
55+
56+
/**
57+
* Returns the set of leaf nodes of the given graph.
58+
*/
59+
public static < V extends Vertex< ? > > RefSet< V > getLeafs( ReadOnlyGraph< V, ? > graph )
60+
{
61+
Predicate< V > isLeaf = spot -> spot.outgoingEdges().isEmpty();
62+
return RefCollectionUtils.filterSet( graph.vertices(), isLeaf );
63+
}
5564
}

0 commit comments

Comments
 (0)