Hey,
Is there any example code on how to use the NetworkDiameter class?

The use case is an unweighted graph where all edge types should be
considered.

Problems I'm having:

   - How do I consider more than 2 edge types?
   - Which node should the startNode be? Is the Reference node alright?
   - How do I define the nodeSet? I would like diameter of the entire graph,
   not of any subgraph/connected component.

My first attempt at setting this up is below but it's obviously not working.
Would be really cool if someone could either give me a sample code snippet,
or point me in the right direction.

Cheers!
Alex

PS, The reason I need this is I'll be using the Diameter value to construct
meaningful simulated access patterns.



CostEvaluator<Integer> costEval = new CostEvaluator<Integer>() {

@Override
public Integer getCost(Relationship relationship, boolean backwards) {
return 1;
}
};

CostAccumulator<Integer> costAcc = new CostAccumulator<Integer>() {

@Override
public Integer addCosts(Integer c1, Integer c2) {
return c1 + c2;
}
};

Comparator<Integer> costComp = new Comparator<Integer>() {

@Override
public int compare(Integer arg0, Integer arg1) {
if (arg0 > arg1)
return -1;
if (arg0 < arg1)
return 1;
return 0;
}
};

Node startNode = graphDb.getReferenceNode();
Integer startCost = 0;
SingleSourceShortestPathDijkstra<Integer> singleSourceShortestPath = new
SingleSourceShortestPathDijkstra<Integer>(
startCost, startNode, costEval, costAcc, costComp, Direction.BOTH,
RelationshipExpander.forTypes(GISRelationshipTypes.FOOT_WAY,
Direction.BOTH, GISRelationshipTypes.BICYCLE_WAY,
Direction.BOTH, GISRelationshipTypes.CAR_WAY,
Direction.BOTH, GISRelationshipTypes.CAR_SHORTEST_WAY,
Direction.BOTH));

Integer zeroValue = 0;

Set<Node> nodeSet = graphDb.getAllNodes();

NetworkDiameter<Integer> networkDiameter = new NetworkDiameter<Integer>(
singleSourceShortestPath, zeroValue, nodeSet, costComp);
_______________________________________________
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to