Search code examples
javagraphjung

converting directed graph to undirected one using java jung library


I am looking for a way to calculate degree of each node of a directedSparseGraph in a undirected way. unfortunately the .degree method give me the sum of indegree and outdegree of each node. Assume directed graph G={(A,B),(B,A),(C,D),(D,A)}. I want to calculate undirected degree for this graph. In this case it would be:A=2, B=1, C=1, D=2.

Regards.


Solution

  • I figure it out myself. This can be done by using .getNeighborCount() method. This method can calculate degree of each node in undirected way.