GraphStream Users

Archives de la liste Aide

Re: Ancestors and descendants

Chronologique Discussions 
  • From: Frederic Guinand <frederic.guinand AT>
  • To: graphstream-users AT, gvdmoort AT
  • Subject: Re: Ancestors and descendants
  • Date: Mon, 31 Mar 2014 23:41:50 +0200


This piece of code should help you.

For a Node n you may use:

ArrayList<? extends Node>ancestors = new ArrayList<? extends Node>();
ArrayList<? extends Node>descendants = new ArrayList<? extends Node>();

Iterator<? extends Edge> inedges = n.getEnteringEdgeIterator();
while(inedges.hasNext()) {

Iterator<? extends Edge> outedges = n.getLeavingEdgeIterator();
while(outedges.hasNext()) {

> Can a graph mix directed and undirected edges ?

The answer is yes, when creating an edge, you just have to set the boolean to


This is an arc from Node sourceId to Node destId.

Hope this helps,



Le 31 mars 2014 à 21:13,
gvdmoort AT
a écrit :

> Hello,
> At first sight, your library seems to fit with my needs. But I don't find in
> the API an easy way to get the set of all the descendants or ancestors of a
> given node in a directed graph. For the descendants, it's possible to use
> the
> BreadthFirstIterator, but for the ancestors ? Is it necessary to make an
> "inversed copy" of the graph ?
> I don't find mention of directed or undirected graphs. Can a graph mix
> directed
> and undirected edges ?
> Thanks in advance,
> gvdm

Archives gérées par MHonArc 2.6.16.

Top of page