Examples of ShortestPath


Examples of ie.transportdublin.shortestpath.ShortestPath

    @BeforeClass
    public static void setup()
    {
        db = new EmbeddedGraphDatabase( "target/db" );
        threeLayeredTraverserShortestPath = new ShortestPath(db);
    }
View Full Code Here

Examples of ie.transportdublin.shortestpath.ShortestPath

    }

    public DirectionsResource( SessionFactoryImpl sessionFactoryImpl, Database database, OutputFormat output )
    {
        this.database = database;
        threeLayeredTraverserShortestPath = new ShortestPath(database.graph);
    }
View Full Code Here

Examples of net.wigis.greg.ShortestPath

    private static ArrayList<ShortestPath> ShortestPath(ArrayList<DNVNode> list, DNVNode source){
     
      ArrayList<ShortestPath> SP = new ArrayList<ShortestPath>();
     
     
      ShortestPath object = new ShortestPath();
      int index = 0;
      int alt = 0;
      boolean end = false;
      boolean stop = false;
     
      ShortestPath node1 = new ShortestPath();
      ShortestPath node2 = new ShortestPath();
     
      //Initialization
      for(int i=0;i<list.size();i++){
        object = new ShortestPath();
        object.setSource(list.get(i));
        object.setDistance(999999999);
        SP.add(object);
      }
     
      //get the source index and set its distance to 0
      for(int i=0;i<SP.size();i++){
        if(source.toString().compareToIgnoreCase(SP.get(i).getSource().toString()) == 0){
          SP.get(i).setDistance(0);
        }
         
      }    
          
      while(list.isEmpty() == false && end == false){       
        //get the node with the lowest distance value
        node1 = getLowerDistanceValueObject(SP,list);
       
        //if the visited node's distance == 9999999999 then we break
        if(node1.getDistance() != 999999999){
         
          list.remove(list.indexOf(node1.getSource()));
            //get all neighbors of the current node
          List<DNVNode> tmp = new ArrayList<DNVNode>(node1.getSource().getNeighbors(true));
            for(int i=0;i<tmp.size();i++){
              //get the DNVNode source value
              DNVNode tempNode = new DNVNode();
             
            tempNode = tmp.get(i);
              //change the previous node2 by the new one
              for(int x=0;x<SP.size();x++){
                if(SP.get(x).getSource().toString().compareToIgnoreCase(tempNode.toString()) == 0){
                  node2 = SP.get(x);
                }
              }          
             
              //get the new distance between both nodes             
              alt = node1.getDistance()+1;
              //if new distance is lower than the previous one, set the new distance and the new previous node
              if(alt < node2.getDistance()){
                node2.setDistance(alt);
                node2.setPreviousNode(node1.getSource());
              }
            }
        }else{
          end = true;
        }
View Full Code Here

Examples of net.wigis.greg.ShortestPath

     * @param source
     * @param destination
     */
    static void highlightPath(ArrayList<ShortestPath> SP, DNVNode source, DNVNode destination){

      ShortestPath currentNode = new ShortestPath();
      boolean loop = true;
     
      //Look for the destination node into the SP list
      for (int i=0;i<SP.size();i++){
        if(SP.get(i).getSource().toString().compareToIgnoreCase(destination.toString()) == 0){
          currentNode = SP.get(i);
        }
      }
     
      destination.setHighlighted(true);

     
      //Loop until the source node is reached
      while(loop){
        //Get the current node's previous node
        DNVNode previousNode = currentNode.getPreviousNode();
        DNVNode nodeVisited = currentNode.getSource();
       
       
        DNVEdge edge = nodeVisited.getEdgeToNeighbor(previousNode.getId());
        edge.setHighlighted(true);
       
View Full Code Here

Examples of org.neo4j.graphalgo.impl.path.ShortestPath

     *            to have.
     * @return an algorithm which finds shortest paths between two nodes.
     */
    public static PathFinder<Path> shortestPath( RelationshipExpander expander, int maxDepth )
    {
        return new ShortestPath( maxDepth, expander );
    }
View Full Code Here

Examples of org.neo4j.graphalgo.impl.path.ShortestPath

     * paths were found.
     * @return an algorithm which finds paths of a certain length between two nodes.
     */
    public static PathFinder<Path> pathsWithLength( RelationshipExpander expander, int length )
    {
        return new ShortestPath( length, expander, true );
    }
View Full Code Here

Examples of org.neo4j.graphalgo.impl.path.ShortestPath

        Node a = graph.getNode( "a" );
        Node b = graph.getNode( "b" );
        Node c = graph.getNode( "c" );
        final Set<Node> allowedNodes = new HashSet<Node>( Arrays.asList( a, b, c ) );
       
        PathFinder<Path> finder = new ShortestPath( 100, Traversal.expanderForAllTypes( Direction.OUTGOING ) )
        {
            @Override
            protected Collection<Node> filterNextLevelNodes( Collection<Node> nextNodes )
            {
                for ( Node node : nextNodes )
                {
                    if ( !allowedNodes.contains( node ) )
                    {
                        fail( "Node " + node.getProperty( KEY_ID ) + " shouldn't be expanded" );
                    }
                }
                return nextNodes;
            }
        };
        finder.findAllPaths( a, c );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.