Examples of DNVGraph


Examples of net.wigis.graph.dnv.DNVGraph

   *            the arguments
   */
  public static void main( String args[] )
  {
    GraphsPathFilter.init();
    DNVGraph graph = new DNVGraph( Settings.GRAPHS_PATH + "_UCI_venezuela.dnv" );
    new MDSLayout().runLayout( graph, 0, true );
    graph.writeGraph( Settings.GRAPHS_PATH + "_UCI_venezuela_MDS.dnv" );
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

    GraphsPathFilter.init();
    String path = Settings.GRAPHS_PATH + "PADA/";
    String nodesFile = "people-w-attributes.csv";
    String co_occurenceFile = "co-occurences-filter-ts2.csv";
   
    DNVGraph graph = new DNVGraph();
   
    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 );
          }
         
          graph.addEntity( 0, edge );
        }
      }
    }
   
    GraphFunctions.removeIsolatedNodes( graph, 0 );
   
    List<DNVNode> nodes = graph.getNodes( 0 );
   
    for( DNVNode tempNode : nodes )
    {
      List<DNVEdge> edges = new ArrayList<DNVEdge>( tempNode.getFromEdges() );
      edges.addAll( tempNode.getToEdges() );
      SortByFloatProperty sbfp = new SortByFloatProperty( "time", true );
      Collections.sort( edges, sbfp );
      tempNode.setProperty( "maxTime", edges.get( 0 ).getProperty( "time" ) );
      tempNode.setProperty( "minTime", edges.get( edges.size()-1 ).getProperty( "time" ) );
    }
   
   
    SortByFloatProperty sbfp = new SortByFloatProperty( "numDocuments", true );
    Collections.sort( nodes, sbfp );
    node = nodes.get( 0 );
    int maxNumDocuments = Integer.parseInt( node.getProperty( "numDocuments" ) );
    System.out.println( "Max number of docs " + maxNumDocuments );
    for( DNVNode tempNode : nodes )
    {
      Vector3D color = new Vector3D( LIGHT_GREEN );
      if( tempNode.hasProperty( "numDocuments" ) )
      {
        Vector3D difference = new Vector3D( LIGHT_RED );
        difference.subtract( color );
        difference.dotProduct( (float)(Integer.parseInt( tempNode.getProperty( "numDocuments" ) ) )/(float)maxNumDocuments );
        color.add( difference );
        color.setX( (float)Math.max( 0, color.getX() ) );
        color.setY( (float)Math.max( 0, color.getY() ) );
        color.setZ( (float)Math.max( 0, color.getZ() ) );
        color.setX( (float)Math.min( 1, color.getX() ) );
        color.setY( (float)Math.min( 1, color.getY() ) );
        color.setZ( (float)Math.min( 1, color.getZ() ) );
      }
      tempNode.setColor( color );
    }
   
    new FruchtermanReingold().runLayout( 100, 100, graph, 0.01f, 0, false, false );

    System.out.println( "Graph has " + graph.getGraphSize( 0 ) + " nodes and " + graph.getEdgeMap( 0 ).size() + " edges." );

    graph.writeGraph( Settings.GRAPHS_PATH + "PADA/" + nodesFile + ".dnv" );
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

   */
  public static void runLayout( String filename )
  {
    System.out.println( "Starting layout for " + filename );

    DNVGraph graph = new DNVGraph( filename );

    runLayout( graph );

    graph.writeGraph( filename.substring( 0, filename.length() - 4 ) + "_laid_out.dnv" );

    System.out.println( "Done with layout for " + filename );
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

  }

  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

Examples of net.wigis.graph.dnv.DNVGraph

    size = Math.max( size, Math.max( GraphFunctions.getGraphHeight( nodes, false ), height ) );
    float temperature = size / 10.0f;

    if( nodes.size() > 0 )
    {
      DNVGraph graph = nodes.iterator().next().getGraph();

      while( temperature > 0 )
      {
        synchronized( graph )
        {
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

  }
 
  public static void main( String args[] )
  {
    GraphsPathFilter.init();
    DNVGraph graph = new DNVGraph( Settings.GRAPHS_PATH + "_UCI_venezuela.dnv" );
    List<DNVNode> nodes = graph.getNodes( 0 );
    SortByLabelSize sbls = new SortByLabelSize( true );
    OrderedList<DNVNode> orderedList = new OrderedList<DNVNode>( sbls, nodes );
    Collections.sort( nodes, sbls );
    for( int i = 0; i < nodes.size(); i++ )
    {
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

  }

  public static void main( String args[] )
  {
    GraphsPathFilter.init();
    DNVGraph graph = new DNVGraph( Settings.GRAPHS_PATH + "UserStudy/testGraphs/graph2large.dnv" );
    UndirectedGraph<DNVNode, JGraphTEdge<DNVNode>> g = convertDNVToUndirectedJGraphT( graph, 0 );
    BiconnectivityInspector<DNVNode, JGraphTEdge<DNVNode>> inspector = new BiconnectivityInspector<DNVNode, JGraphTEdge<DNVNode>>( g );
    System.out.println( inspector.isBiconnected() );
    Set<Set<DNVNode>> components = inspector.getBiconnectedVertexComponents();
    System.out.println( "graph contains " + components.size() + " biconnected components" );
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

  // // private static Log logger = LogFactory.getLog(
  // GenerateDNVGraphFromDB.class );

  public static DNVGraph generateGraph( String graphName, boolean generateMultipleLevels )
  {
    DNVGraph graph = new DNVGraph();

    try
    {
      DBManager dbm = new DBManager( "brynj001_graphs" );
      String query = "SELECT * FROM graphs WHERE name = '" + graphName + "'";
      ResultSet results = dbm.getResults( query );
      results.first();
      int idGraphs = results.getInt( "idGraphs" );
      query = "SELECT * FROM nodes WHERE idGraphs = " + idGraphs + ";";
      results = dbm.getResults( query );
      results.last();
      System.out.println( "Processing " + results.getRow() + " nodes" );
      results.beforeFirst();
      DNVNode newNode;
      Vector2D position;
      float r, g = 0, b = 0;
      r = graphName.charAt( 0 ) / 120.0f;

      if( graphName.length() > 1 )
        g = graphName.charAt( graphName.length() / 2 ) / 150.0f;
      if( graphName.length() > 2 )
        b = graphName.charAt( graphName.length() - 1 ) / 100.0f;
      while( results.next() )
      {
        position = new Vector2D( 100.0f * (float)Math.random(), 100.0f * (float)Math.random() );
        // position = new Vector2D( results.getFloat( "xPos" ),
        // results.getFloat( "yPos" ) );
        newNode = new DNVNode( position, graph );
        newNode.setColor( r, g, b );
        newNode.setPosition( position );
        newNode.setRadius( results.getFloat( "radius" ) );
        newNode.setMass( results.getFloat( "mass" ) );
        newNode.setLevel( 0 );
        newNode.setId( results.getInt( "idNodes" ) );
        graph.addNode( 0, newNode );
      }

      query = "SELECT * FROM edges WHERE idGraphs = " + idGraphs + ";";
      System.out.println( query );
      results = dbm.getResults( query );
      results.last();
      System.out.println( "Processing " + results.getRow() + " edges" );
      results.beforeFirst();
      DNVEdge newEdge;
      DNVNode fromNode;
      DNVNode toNode;
      while( results.next() )
      {
        fromNode = (DNVNode)graph.getNodeById( results.getInt( "fromNodeId" ) );
        toNode = (DNVNode)graph.getNodeById( results.getInt( "toNodeId" ) );
        newEdge = new DNVEdge( 0, DNVEdge.DEFAULT_RESTING_DISTANCE, false, fromNode, toNode, graph );
        if( fromNode != null && toNode != null )
        {
          fromNode.addFromEdge( newEdge );
          toNode.addToEdge( newEdge );
          graph.addNode( 0, newEdge );
        }
        else
          System.out.println( "Error with a node for edge " + results.getInt( "fromNodeId" ) + "->" + results.getInt( "toNodeId" ) );

      }

      if( generateMultipleLevels )
      {
        System.out.println( "Creating multilevels" );
        int level = 0;

        int numberOfClusters = graph.getGraphSize( level ) / DIVIDER;
        while( numberOfClusters > 0 )
        {
          KMostConnected.cluster( graph, numberOfClusters, level, true );
          level++;
          numberOfClusters = ( graph.getGraphSize( level ) - graph.getNumberOfDisconnectedNodes( level ) ) / DIVIDER;
        }

        System.out.println( "Initializing positions" );
        GraphFunctions.initializePositions( graph );
      }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

   * @param args
   *            the arguments
   */
  public static void main( String args[] )
  {
    DNVGraph graph = generateGraph( "uk", true );
    graph.writeGraph( "C:\\BLACKBOOK\\bball\\SOA\\3.dnv" );
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

      String edgesLocator ) throws IOException
  {
    System.out.println( "Converting " + inputFile + " to Tom Sawyer format." );
    System.out.println( "Output can be found in " + outputFile );
    counter = 10;
    DNVGraph graph = new DNVGraph( inputFile );
    FileReader fr = new FileReader( templateFile );
    BufferedReader br = new BufferedReader( fr );
    FileWriter fw = new FileWriter( outputFile );

    String line = br.readLine();
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.