org.nlogo.agent
Class NetworkMetrics

java.lang.Object
  extended by org.nlogo.agent.NetworkMetrics

public class NetworkMetrics
extends Object


Method Summary
 double averagePathLength(AgentSet nodeSet, AgentSet linkBreed)
          Calculates the average shortest-path length between all (distinct) pairs of nodes in the given nodeSet, by traveling along links of the given linkBreed.
 Set<Turtle> inNetworkRadius(Turtle sourceNode, AgentSet sourceSet, double radius, AgentSet linkBreed)
          This method performs a BFS from the sourceNode, following the network imposed by the given linkBreed, going up to radius layers out, and only collecting nodes that are members of sourceSet.
 int networkDistance(Turtle sourceNode, Turtle destNode, AgentSet linkBreed)
          This method performs a BFS from the sourceNode, following the network imposed by the given linkBreed, to find the distance to destNode.
 LogoList networkShortestPathLinks(org.nlogo.util.MersenneTwisterFast random, Turtle sourceNode, Turtle destNode, AgentSet linkBreed)
           
 LogoList networkShortestPathNodes(org.nlogo.util.MersenneTwisterFast random, Turtle sourceNode, Turtle destNode, AgentSet linkBreed)
          This method performs a BFS from the sourceNode, following the network imposed by the given linkBreed, to find the shortest path to destNode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

inNetworkRadius

public Set<Turtle> inNetworkRadius(Turtle sourceNode,
                                   AgentSet sourceSet,
                                   double radius,
                                   AgentSet linkBreed)
This method performs a BFS from the sourceNode, following the network imposed by the given linkBreed, going up to radius layers out, and only collecting nodes that are members of sourceSet. Note: this method follows directed links both directions. But we could change its functionality when dealing with directed links -- I'm not sure what the right thing is. ~Forrest (5/11/2007)


networkDistance

public int networkDistance(Turtle sourceNode,
                           Turtle destNode,
                           AgentSet linkBreed)
This method performs a BFS from the sourceNode, following the network imposed by the given linkBreed, to find the distance to destNode. Directed links are only followed in the "forward" direction. It returns -1 if there is no path between the two nodes. ~Forrest (5/11/2007)


networkShortestPathNodes

public LogoList networkShortestPathNodes(org.nlogo.util.MersenneTwisterFast random,
                                         Turtle sourceNode,
                                         Turtle destNode,
                                         AgentSet linkBreed)
This method performs a BFS from the sourceNode, following the network imposed by the given linkBreed, to find the shortest path to destNode. Directed links are only followed in the "forward" direction. It returns an empty list if there is no path between the two nodes. The BFS proceeds in a random order, so if there are multiple shortest paths, a random one will be returned. Note, however, that the probability distribution of this random choice is subtly different from if we had enumerated *all* shortest paths, and chose one of them uniformly at random. I don't think there is an efficient way to implement it that other way. ~Forrest (5/11/2007)


networkShortestPathLinks

public LogoList networkShortestPathLinks(org.nlogo.util.MersenneTwisterFast random,
                                         Turtle sourceNode,
                                         Turtle destNode,
                                         AgentSet linkBreed)

averagePathLength

public double averagePathLength(AgentSet nodeSet,
                                AgentSet linkBreed)
Calculates the average shortest-path length between all (distinct) pairs of nodes in the given nodeSet, by traveling along links of the given linkBreed. It returns -1 if any two nodes in nodeSet are not connected by a path. Note: this method follows directed links both directions. But we could change its functionality when dealing with directed links -- I'm not sure what the right thing is. Seems like often the average path length (when only following links "forward)in a directed-graph would be undefined. ~Forrest (5/11/2007)