Question

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.

Was it helpful?

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.

OTHER TIPS

FYI, the degree of the node is the number of incident edges. The number of neighbors is the number of nodes which are connected by a single edge. In the case of your example these should be identical; you only start getting discrepancies in the case of parallel or antiparallel edges, or self loops.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top