algorithm to use to return a specific range of nodes in a directed graph
Posted
by GatesReign
on Stack Overflow
See other posts from Stack Overflow
or by GatesReign
Published on 2010-04-17T05:27:15Z
Indexed on
2010/04/17
5:33 UTC
Read the original article
Hit count: 528
I have a class Graph with two lists types namely nodes and edges
I have a function
List<int> GetNodesInRange(Graph graph, int Range)
when I get these parameters I need an algorithm that will go through the graph and return the list of nodes only as deep (the level) as the range. The algorithm should be able to accommodate large number of nodes and large ranges.
Atop this, should I use a similar function
List<int> GetNodesInRange(Graph graph, int Range, int selected)
I want to be able to search outwards from it, to the number of nodes outwards (range) specified.
So in the first function, I expect it to return the nodes placed in the blue box. The other function, if I pass the nodes as in the graph with a range of 1 and it starts at node 5, I want it to return the list of nodes that satisfy this criteria (placed in the orange box)
© Stack Overflow or respective owner