Package net.wigis.graph.dnv

Examples of net.wigis.graph.dnv.DNVNode


    for( DNVNode tempNode : graph.getNodes( level ) )
    {
      tempNode.setColor( 1, 1, 1 );
    }

    DNVNode activeNode = GraphFunctions.getNodeByType( centerType, graph, level );
    DNVNode[] peersholder = GraphFunctions.getKNearestNodes( k, activeNode, graph, level, false, peersType );

    for( int i = 0; i < peersholder.length; i++ )
    {
      peersholder[i].setColor( 1f, 0.5f, 0.5f );
View Full Code Here


   * @return true, if successful
   */
  public static boolean areConnected( DNVNode itemNode, DNVNode friendNode )
  {
    Map<Integer, DNVNode> neighborMap = itemNode.getNeighborMap();
    DNVNode node = neighborMap.get( friendNode.getId() );
    if( node != null )
      return true;

    return false;
  }
View Full Code Here

    for( GraphPath<DNVNode,JGraphTEdge<DNVNode>> path : thePaths )
    {
      List<DNVNode> tempPath = new ArrayList<DNVNode>();
      tempPath.add( path.getStartVertex() );
      DNVNode lastNode = path.getStartVertex();
      for( JGraphTEdge<DNVNode> edge : path.getEdgeList() )
      {
        if( edge.getSource() == lastNode )
        {
          tempPath.add( edge.getTarget() );
View Full Code Here

 
  public static DNVNode getMostFrequentIntermediateNode( DNVGraph graph, int level, DNVNode startNode, DNVNode endNode, int maxNumberOfPaths )
  {
    int numberOfPaths = 0;
    boolean done = false;
    DNVNode mostFrequentNode = null;
    DNVNode secondMostFrequentNode;
    while( !done )
    {
      numberOfPaths += 100;
//      System.out.println( numberOfPaths );
      List<DNVNode> allNodes = getNodesSortedByFrequencyOnShortestPath( graph, level, startNode, endNode, numberOfPaths );
      if( allNodes == null )
      {
        return null;
      }
      mostFrequentNode = null;
      secondMostFrequentNode = null;
      for( DNVNode node : allNodes )
      {
        if( node != startNode && node != endNode )
        {
          if( mostFrequentNode == null )
          {
            mostFrequentNode = node;
          }
          else
          {
            secondMostFrequentNode = node;
            break;
          }
        }
      }
     
      int count1 = Integer.parseInt( mostFrequentNode.getProperty( "nodeCount" ) );
      int count2 = Integer.parseInt( secondMostFrequentNode.getProperty( "nodeCount" ) );
//      System.out.println( "First candidate:" + mostFrequentNode.getLabel() );
//      System.out.println( "Second candidate:" + secondMostFrequentNode.getLabel() );
//      System.out.println( "diff:" + Math.abs( count1 - count2 ) );
//      System.out.println( "percentage:" + count1 / (double)numberOfPaths );
      if( (count1 / (double)numberOfPaths) > 0.7 /*|| Math.abs( count1 - count2 ) >= numberOfPaths * 0.1*/ || numberOfPaths >= maxNumberOfPaths )
View Full Code Here

  public static void main( String args[] )
  {
    GraphsPathFilter.init();
    DNVGraph graph = new DNVGraph( Settings.GRAPHS_PATH + "UserStudy/testGraphs/graph1small.dnv" );
    DNVNode startNode = graph.getNodes().get( (int)(Math.random()*graph.getNodes().size()) );
    DNVNode endNode = graph.getNodes().get( (int)(Math.random()*graph.getNodes().size()) );
    DNVNode frequent = getMostFrequentIntermediateNode( graph, 0, startNode, endNode, 1000 );
   
    System.out.println( "Most frequent node " + frequent.getLabel() + " with " + frequent.getProperty( "pathFrequency_" + startNode.getId() + "_" + endNode.getId() ) + " occurrances." );
    
  }
View Full Code Here

  // connected components
  // --------------------------------
  public void selectNode() {
    int index = Integer.parseInt(__jsf.getParam());

    DNVNode n = PaintBean.getCurrentInstance().getGraph().getNodes(0).get(index);

    PaintBean.getCurrentInstance().getGraph().unsellectAllNodes();

    n.setSelected(true);
  }
View Full Code Here

    dehighlightAndDeSelectNodesAndEdges();

    // highlight nodes
    for (int x = 0; x < nodes.size(); x++) {
      DNVNode toFind = (DNVNode) PaintBean.getCurrentInstance().getGraph().getNodeById(nodes.get(x));
      int index = nodesList.indexOf(toFind);
      DNVNode node = nodesList.get(index);
      node.setSelected(true);
    }
  }
View Full Code Here

    dehighlightAndDeSelectNodesAndEdges();

    // highlight nodes
    for (int x = 0; x < nodes.size(); x++) {
      DNVNode toFind = (DNVNode) PaintBean.getCurrentInstance().getGraph().getNodeById(nodes.get(x));
      int index = nodesList.indexOf(toFind);
      DNVNode node = nodesList.get(index);
      node.setSelected(true);
    }

    // highlight edges
    for (int x = 0; x < edges.size(); x++) {
      for (int y = 0; y < edgesList.size(); y++) {
View Full Code Here

    dehighlightAndDeSelectNodesAndEdges();

    // highlight nodes
    for (int x = 0; x < nodes.size(); x++) {
      DNVNode toFind = (DNVNode) PaintBean.getCurrentInstance().getGraph().getNodeById(nodes.get(x));
      int index = nodesList.indexOf(toFind);
      DNVNode node = nodesList.get(index);
      node.setSelected(true);
    }

    // highlight edges
    for (int x = 0; x < edges.size(); x++) {
      for (int y = 0; y < edgesList.size(); y++) {
View Full Code Here

   * @return string averagePathLength, the result
   */
  public static String computeAveragePathLength(List<DNVNode> selectedNodes)
  { 
    ArrayList<DNVNode> nodeList = new ArrayList<DNVNode>(selectedNodes);
    DNVNode nodeBeingVisited = new DNVNode();
    double averagePathLength = 0.0;
   
    int nodeBeingVisitedWeight = 0;
    int temp = 0;
   
    ArrayList<DNVNode> tmp = new ArrayList<DNVNode>();
    ArrayList<NextNode> nextNode = new ArrayList<NextNode>();
    Hashtable<DNVNode, Integer> visitedNode = new Hashtable<DNVNode, Integer>();
   
    Enumeration e;
    String key = "";
    String result = "";
    Double counter = 0.0;
    Double sum = 0.0;
    Double degree = 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++)
      {
        for(int y=0;y<selectedNodes.size();y++){
          if(tmp.get(i).equals(selectedNodes.get(y))){
            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++)
          {
            for(int y=0;y<selectedNodes.size();y++){
              if(tmp.get(x).equals(selectedNodes.get(y))){
                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

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.