Package net.wigis.graph.dnv

Examples of net.wigis.graph.dnv.DNVNode


    String line;
    String from;
    String to;

    DNVGraph graph = new DNVGraph();
    DNVNode fromNode;
    DNVNode toNode;
    DNVEdge edge;

    while( ( line = br.readLine() ) != null )
    {
      from = line.substring( 0, line.indexOf( "\t" ) ).trim();
View Full Code Here


  private static DNVEntity getNode( String bbid, DNVGraph graph )
  {
    DNVEntity node = graph.getNodeByBbId( bbid );
    if( node == null )
    {
      node = new DNVNode( graph );
      node.setLabel( bbid );
      node.setBbId( bbid );
      node.setColor( "#33FF33" );
      ( (DNVNode)node ).setPosition( (float)( Math.random() * 100.0 ), (float)( Math.random() * 100.0 ) );
      graph.addNode( 0, node );
View Full Code Here

    {
      System.out.println();
      System.out.println( filename );
      DNVGraph tempGraph = new DNVGraph( directory + filename );
      List<DNVNode> nodes = tempGraph.getNodes( 0 );
      DNVNode newNode;
      for( DNVNode node : nodes )
      {
        if( node.getBbId() != null && !node.getBbId().equals("") )
        {
          System.out.println( "Friend" );
          System.out.println( node.getLabel() );
          if( graph.getNodeByBbId( node.getLabel() ) == null )
          {
            newNode = new DNVNode(graph);
            newNode.setLabel( node.getLabel() );
            newNode.setBbId( node.getLabel() );
            newNode.setColor( 0.5f, 0.5f, 1 );
            newNode.setPosition( (float)Math.random(), (float)Math.random() );
            newNode.setType( "person" );
            graph.addNode( 0, newNode );
          }
        }
        else
        {
          if( !ignoreItems )
          {
            System.out.println( "Item" );
            System.out.println( node.getLabel() );
            if( graph.getNodeByBbId( node.getLabel() ) == null )
            {
              newNode = new DNVNode(graph);
              newNode.setLabel( node.getLabel() );
              newNode.setBbId( node.getLabel() );
              newNode.setColor( 1.0f, 1.0f, 0 );
              newNode.setPosition( (float)Math.random(), (float)Math.random() );
              newNode.setType( "item" );
              graph.addNode( 0, newNode );
            }
          }
        }
      }
     
      List<DNVEdge> edges = tempGraph.getEdges( 0 );
      for( DNVEdge edge : edges )
      {
        System.out.println( edge.getFrom().getLabel() + "->" + edge.getTo().getLabel() );
        if( graph.getNodeByBbId( edge.getFrom().getLabel() + "->" + edge.getTo().getLabel() ) == null )
        {
          DNVNode fromNode = (DNVNode)graph.getNodeByBbId( edge.getFrom().getLabel() );
          DNVNode toNode = (DNVNode)graph.getNodeByBbId( edge.getTo().getLabel() );
          if( fromNode != null && toNode != null )
          {
            DNVEdge newEdge = new DNVEdge( fromNode, toNode, graph );
            newEdge.setBbId( fromNode.getLabel() + "->" + toNode.getLabel() );
            newEdge.setType( "likes" );
            graph.addEntity( 0, newEdge );
          }
        }
      }
     
      if( generateFriendEdges )
      {
        DNVNode tempUserNode = (DNVNode)tempGraph.getNodesByType( 0, "user" ).get( 0 );
        if( tempUserNode != null )
        {
          DNVNode userNode = (DNVNode)graph.getNodeByBbId( tempUserNode.getLabel() );
          Map<Integer,DNVEntity> friends = tempGraph.getNodesByType( 0, "friend" );
          for( DNVEntity friend : friends.values() )
          {
            DNVNode friendNode = (DNVNode)graph.getNodeByBbId( friend.getLabel() );
            DNVEdge newEdge = new DNVEdge( userNode, friendNode, graph );
            newEdge.setBbId( userNode.getLabel() + "->" + friendNode.getLabel() );
            newEdge.setType( "friendEdge" );
            graph.addEntity( 0, newEdge );
          }
        }
      }
View Full Code Here

    else
    {
      output = MDSJ.classicalScaling( dissimilarityMatrix );
    }

    DNVNode tempNode;
    for( int i = 0; i < nodes.size(); i++ )
    {
      tempNode = nodes.get( i );
      tempNode.setPosition( (float)output[0][i], (float)output[1][i] );
    }

    printMatrix( output );
  }
View Full Code Here

   */
  private static double[][] createDissimilarityMatrix( List<DNVNode> nodes )
  {
    double[][] dissimilarityMatrix = new double[nodes.size()][nodes.size()];

    DNVNode node1;
    DNVNode node2;
    int count = 0;
    double maxValue = 0;
    double value;
    for( int i = 0; i < nodes.size(); i++ )
    {
View Full Code Here

    File file = new File( path, nodesFile );
    FileReader fr = new FileReader( file );
    CSVReader csv = new CSVReader( fr );
   
    String[] line;
    DNVNode node;
    while( (line=csv.readNext()) != null )
    {
      if( !line[0].equals( "" ) )
      {
        node = (DNVNode)graph.getNodeByBbId( line[0] );
        if( node == null )
        {
  //        if( line[3].trim().equals( "1" ) )
  //        {
            node = new DNVNode( graph );
            node.setBbId( line[0] );
            node.setProperty( "numDocuments", line[1] );
            node.setProperty( "numFamilyRelations", line[2] );
            node.setProperty( "hasFamilyRelation", line[3] );
            if( line[3].trim().equals( "1" ) )
            {
              node.setProperty( "Contents", "hasFamilyRelation" );
            }
            node.setPosition( (float)Math.random(), (float)Math.random() );
            node.setLabel( line[4] );
           
            graph.addNode( 0, node );
  //        }
        }
        else
        {
          System.out.println( "Multiple occurances of same node: " + line[0] );
        }
      } 
    }
    csv.close();
    fr.close();
    System.out.println( "Added " + graph.getGraphSize( 0 ) + " nodes to the graph." );
   
    file = new File( path, co_occurenceFile );
    fr = new FileReader( file );
    csv = new CSVReader( fr );
    DNVNode node1;
    DNVNode node2;
    DNVEdge edge;
    long time;
    while( (line=csv.readNext()) != null )
    {
      if( !line[0].equals( "" ) )
      {
        node1 = (DNVNode)graph.getNodeByBbId( line[0] );
        node2 = (DNVNode)graph.getNodeByBbId( line[1] );
        if( !node1.getNeighborMap().containsKey( node2.getId() ) )
        {
          edge = new DNVEdge( node1, node2, graph );
          edge.setBbId( node1.getBbId() + "->" + node2.getBbId() );
          time = convertTimeStampToLong( line[3] );
          if( time != -1 )
          {
            edge.setProperty( "time", "" + time );
          }
View Full Code Here

   */
  private static Map<Integer, Integer> generateHistogramOfSubnodes( DNVGraph graph, int level )
  {
    HashMap<Integer, Integer> histogram = new HashMap<Integer, Integer>();
    List<DNVNode> nodes = graph.getNodes( level );
    DNVNode tempNode;
    Integer numberOfSubnodes;
    Integer counter;
    for( int i = 0; i < nodes.size(); i++ )
    {
      tempNode = nodes.get( i );
      numberOfSubnodes = tempNode.getNumberOfSubNodes();
      counter = histogram.get( numberOfSubnodes );
      if( counter == null )
      {
        counter = 0;
      }
View Full Code Here

        }
        nodesForOneIteration.addAll(centralNodes);
        for(DNVNode node : centralNodes){
          node.setVisible(true);
          for(DNVEdge edge : node.getFromEdges()){
            DNVNode toNode = edge.getTo();
            if(!traveledEdges.contains(edge) && traveledNodes.contains(toNode)){
              traveledEdges.add(edge);
              edge.setProperty("pinned", "true");
              edge.setProperty("time", step+"");
              edge.setProperty("minTime", "0");
              edge.setProperty("maxTime", "100000");
              edge.updateEntityTimeInGraph();
              edge.setVisible(true);
            }else if(!traveledNodes.contains(toNode)){
              toNode.setVisible(true);
              nodesForOneIteration.add(toNode);
              traveledNodes.add(toNode);
            }
          }
          for(DNVEdge edge : node.getToEdges()){
            DNVNode fromNode = edge.getFrom();
            if(!traveledEdges.contains(edge) && traveledNodes.contains(fromNode)){
              traveledEdges.add(edge);
              edge.setVisible(true);
              edge.setProperty("pinned", "true");
              edge.setProperty("time", step+"");
              edge.setProperty("minTime", "0");
              edge.setProperty("maxTime", "100000");
              edge.updateEntityTimeInGraph();
            }else if(!traveledNodes.contains(fromNode)){
              fromNode.setVisible(true);
              nodesForOneIteration.add(fromNode);
              traveledNodes.add(fromNode);
            }
          }
        }
View Full Code Here

  public static float getMaxXPosition( Collection<DNVNode> nodeList, boolean display )
  {
    if( nodeList != null )
    {
      Iterator<DNVNode> nodes = nodeList.iterator();
      DNVNode tempNode = null;
      float max = Float.NEGATIVE_INFINITY;
      float temp;
      while( nodes.hasNext() )
      {
        tempNode = nodes.next();
        temp = tempNode.getPosition( display ).getX();
        if( temp > max )
          max = temp;
      }

      return max;
View Full Code Here

  public static float getMaxYPosition( Collection<DNVNode> nodeList, boolean display )
  {
    if( nodeList != null )
    {
      Iterator<DNVNode> nodes = nodeList.iterator();
      DNVNode tempNode = null;
      float max = Float.NEGATIVE_INFINITY;
      float temp;
      while( nodes.hasNext() )
      {
        tempNode = nodes.next();
        temp = tempNode.getPosition( display ).getY();
        if( temp > max )
          max = temp;
      }

      return max;
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.