protected Set < Integer > getNeighbors ( int node ) { Set < Integer > neighbors = new HashSet < Integer > ( ) ; Set < DefaultEdge > edges = undirectedGraph . edgesOf ( node ) ; for ( DefaultEdge edge : edges ) { if ( undirectedGraph . getEdgeSource ( edge ) != node ) { neighbors . add ( undirectedGraph . getEdgeSource ( edge ) ) ; } if ( undirectedGraph . getEdgeTarget ( edge ) != node ) { neighbors . add ( undirectedGraph . getEdgeTarget ( edge ) ) ; } } return neighbors ; }
Get the neighbors of a given node . The category graph is treated as an undirected graph .