Package net.wigis.graph.dnv

Examples of net.wigis.graph.dnv.DNVNode


    int outDegree = 0;
    String res = "";
   
   
    for(int i=0;i<edgesList.size();i++){
      DNVNode to = edgesList.get(i).getTo();
      DNVNode from = edgesList.get(i).getFrom();
      if(to.toString().compareToIgnoreCase(node.toString()) == 0){
        inDegree++;
      }else if(from.toString().compareToIgnoreCase(node.toString()) == 0){
        outDegree++;
      }
    }
   
    res = Integer.toString(inDegree)+"?"+Integer.toString(outDegree);
View Full Code Here


    selectedNode.setDistanceFromSelectedNode( 0 );
    selectedNode.setActualDistanceFromSelectedNode( 0 );
    selectedNode.setDistanceFromNode( selectedNode, 0 );
    Iterator<DNVEdge> edges;
    queue.add( selectedNode );
    DNVNode tempNode;
    float actualDistance;
    int maxDistance = 0;
    int distance;
    float maxActualDistance = 0;
    DNVEdge tempEdge;
    if( maxDepth > 0 )
    {
      while( queue.size() > 0 )
      {
        tempNode = queue.remove( 0 );
        distance = tempNode.getDistanceFromNodeWithId( selectedNode.getId() );
        actualDistance = tempNode.getActualDistanceFromSelectedNode();
        if( actualDistance > maxActualDistance )
        {
          maxActualDistance = actualDistance;
        }

        if( distance > maxDistance )
        {
          maxDistance = distance;
        }

        if( distance < maxDepth )
        {
          // From edges
          edges = tempNode.getFromEdges().iterator();
          while( edges.hasNext() )
          {
            tempEdge = edges.next();
            if( tempEdge.isVisible() )
            {
              addNode( selectedNode, distance + 1, actualDistance + tempEdge.getRestingDistance(), queue, tempEdge.getTo() );
            }
          }

          // To edges
          edges = tempNode.getToEdges().iterator();
          while( edges.hasNext() )
          {
            tempEdge = edges.next();
            if( tempEdge.isVisible() )
            {
View Full Code Here

   */
  public static void setWeights( DNVGraph graph, Integer level, float maxDistance, float scalar1, float scalar2, float sCurveLowEnd, float sCurveHighEnd,
      boolean useActualDistance, DNVNode selectedNode )
  {
    Timer weightsTimer = new Timer( Timer.MILLISECONDS );
    DNVNode tempNode;
    float tempWeight;
    weightsTimer.setStart();
    Iterator<DNVNode> nodes = graph.getNodes( level ).iterator();
    float tempDistance;
    while( nodes.hasNext() )
    {
      tempNode = nodes.next();
      if( useActualDistance )
        tempDistance = tempNode.getActualDistanceFromSelectedNode();
      else
        tempDistance = tempNode.getDistanceFromNodeWithId( selectedNode.getId() );

      if( tempDistance != Integer.MAX_VALUE )
      {
        graph.addInterpolationNode( tempNode, level );
        tempWeight = 1.0f - ( ( tempDistance ) / ( maxDistance ) );
        // tempWeight = 1.0f / (tempDistance + 1);
        // System.out.println( "1.0 - (" +
        // tempNode.getDistanceFromSelectedNode() + " / " + maxDistance
        // + ") = " + tempWeight );
        if( tempWeight > sCurveLowEnd )
        {
          // tempWeight = ( tempWeight - sCurveLowEnd ) / (
          // sCurveHighEnd - sCurveLowEnd );
          // tempWeight = scalar1 * tempWeight * tempWeight - scalar2
          // * tempWeight * tempWeight * tempWeight;
          tempNode.setInterpolationWeight( selectedNode.getId(), tempWeight );
        }
      }
      else
      {
        tempWeight = 0;
        tempNode.setInterpolationWeight( selectedNode.getId(), tempWeight );
      }
    }

    weightsTimer.setEnd();
    if( Settings.DEBUG )
View Full Code Here

    applyTimer.setStart();
    Timer moveTimer = new Timer( Timer.MILLISECONDS );
    if( selectedNode != null )
    {
      List<DNVNode> nodes = graph.getInterpolationList( level );
      DNVNode tempNode;
      Vector2D tempMove = new Vector2D();
      for( int i = 0; i < nodes.size(); i++ )
      {
        tempNode = nodes.get( i );
        if( tempNode.getDistanceFromNodeWithId( selectedNode.getId() ) != Integer.MAX_VALUE && !tempNode.isSelected() && selectedNode != null )
        {
          tempMove.set( movement );
          if( tempNode != null && selectedNode != null )
          {
            tempMove.dotProduct( tempNode.getInterpolationWeight( selectedNode.getId() ) );
          }

          // System.out.println(
          // tempNode.getDistanceFromSelectedNode() +
          // " : " + tempNode.getInterpolationWeight() + " : " +
          // tempMove
          // + " : " + tempMove.length() );
          moveTimer.setStart();
          tempNode.move( tempMove, true, false );
          moveTimer.setEnd();
        }
      }

      if( pb.isAvoidNodeOverlap() )
View Full Code Here

   * @return string averagePathLength, the result
   */
  public static String computeAveragePathLength(DNVGraph graph)
  {         
    ArrayList<DNVNode> nodeList = new ArrayList<DNVNode>(graph.getVisibleNodes(0).values());
    DNVNode nodeBeingVisited = new DNVNode();
    double averagePathLength = 0.0;
   
    int nodeBeingVisitedWeight = 0;
    int temp = 0;
    Double degree = 0.0;
   
    ArrayList<DNVNode> tmp = new ArrayList<DNVNode>();
    ArrayList<NextNode> nextNode = new ArrayList<NextNode>();
    Hashtable<DNVNode, Integer> visitedNode = new Hashtable<DNVNode, Integer>();
   
    Enumeration e;
    String result = "";
    Double counter = 0.0;
    Double sum = 0.0;
   
    int values = 0;
    int size = 0;
   
   
    //For all nodes from the node list
    for(int n=0;n<nodeList.size();n++)
    {
      visitedNode = new Hashtable<DNVNode, Integer>();
      nextNode = new ArrayList<NextNode>();
     
      //get the current node being visited
      nodeBeingVisited = nodeList.get(n);
     
      nodeBeingVisitedWeight = 0;

      //get all of the current node neighbors
      tmp = (ArrayList<DNVNode>) nodeBeingVisited.getNeighbors(true);
     
      temp = nodeBeingVisitedWeight+1;
      for(int i=0;i<tmp.size();i++)
      {
        nextNode.add(new NextNode(tmp.get(i),temp));

      }
     
      //Add the current node to the visited node list
      visitedNode.put(nodeBeingVisited,nodeBeingVisitedWeight);
     
      //While the next node list is not empty
      while(nextNode.isEmpty() == false)
      {
        //Get the current node being visited
        nodeBeingVisited = nextNode.get(0).getNode();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
       
        //if the node hasn't been visited yet
        if(visitedNode.containsKey(nodeBeingVisited) == false)
        {
          nodeBeingVisitedWeight = nextNode.get(0).getWeight();
         
          //get its neighbors & add them at the end of the next node list
          tmp = (ArrayList<DNVNode>) nodeBeingVisited.getNeighbors(true);
          temp = nodeBeingVisitedWeight + 1;
          for(int x=0;x<tmp.size();x++)
          {
            nextNode.add(new NextNode(tmp.get(x),temp));
          }
         
          //add the current node into the visited node list
          visitedNode.put(nodeBeingVisited,nodeBeingVisitedWeight);
        }
        //remove the node from the next node list
        nextNode.remove(0);
      }
     
      values = 0;
      e = visitedNode.keys();
     
      //get all the weights ans add them up together
        while (e.hasMoreElements()){
          Object str = e.nextElement();
          values += visitedNode.get(str);
        }
       
      size = visitedNode.size();
     
      //get the APL for the current node
      sum += Double.parseDouble(Integer.toString(values))/Double.parseDouble(Integer.toString(size));
     
      counter++;
     
      degree += nodeBeingVisited.getDegree();
     
     
     
    }
   
View Full Code Here

          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             
View Full Code Here

     
      //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);
       
       
       
        previousNode.setHighlighted(true);
View Full Code Here

     */
    private static ArrayList<DNVNode> getCluster(DNVGraph graph, DNVNode start){
      ArrayList<DNVNode> result = new ArrayList<DNVNode>();
      ArrayList<DNVNode> nextNodes = new ArrayList<DNVNode>();
      ArrayList<DNVNode> tmp = new ArrayList<DNVNode>();
      DNVNode currentNode = new DNVNode();
      boolean found = false;
     
      //set up the start node
      nextNodes.add(start);
     
      //while all the nodes hasn't been explored yet
      while(nextNodes.isEmpty() == false){
        //get the current node
        currentNode = nextNodes.get(0);
        nextNodes.remove(0);
        if(result.contains(currentNode) == false){
          result.add(currentNode);
          tmp = (ArrayList<DNVNode>) currentNode.getNeighbors(true);
          //loop on all the visible neighbors
          for(int i=0;i<tmp.size();i++){
            if(result.contains(tmp.get(i))){
              found = true;
            }
View Full Code Here

       

        vertex_index = new ArrayList<DNVNode>(2 * init_vertices);
        //index_vertex = new HashMap<DNVNode, Integer>(2 * init_vertices);
        for (int i = 0; i < init_vertices; i++) {
            DNVNode node = new DNVNode(mGraph);
            mGraph.addNode(0, node);
            vertex_index.add(node);
            //index_vertex.put(node, i);
        }

View Full Code Here

        mElapsedTimeSteps = 0;
    }
    private void createRandomEdge(List<DNVNode> preexistingNodes,
      DNVNode newNode, HashSet<Pair<DNVNode, DNVNode>> added_pairs) {
      DNVNode attach_point;
        boolean created_edge = false;
        Pair<DNVNode, DNVNode> endpoints;
        do {
            attach_point = vertex_index.get(mRandom
                    .nextInt(vertex_index.size()));

            endpoints = new Pair<DNVNode, DNVNode>(newNode, attach_point);

            // if parallel edges are not allowed, skip attach_point if <newNode, attach_point>
            // already exists; note that because of the way edges are added, we only need to check
            // the list of candidate edges for duplicates.
            if (added_pairs.contains(endpoints) || added_pairs.contains(new Pair<DNVNode, DNVNode>(attach_point, newNode)))
              continue;

            double degree = attach_point.getDegree();

            // subtract 1 from numVertices because we don't want to count newNode
            // (which has already been added to the graph, but not to vertex_index)
            double attach_prob = (degree + 1)
                    / (mGraph.getEdges().size() + mGraph.getNodes(0).size() - 1);
View Full Code Here

TOP

Related Classes of net.wigis.graph.dnv.DNVNode

Copyright © 2018 www.massapicom. 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.