Examples of DNVGraph


Examples of net.wigis.graph.dnv.DNVGraph

    public BarabasiAlbertGenerator(int init_vertices, int numEdgesToAttach) {
        this (init_vertices, numEdgesToAttach, (int) System.currentTimeMillis());
    }
    private void initialize() {

        mGraph = new DNVGraph();
       

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

Examples of net.wigis.graph.dnv.DNVGraph

    }
   
    public static void main(String[] args){
      BarabasiAlbertGenerator bsg = new BarabasiAlbertGenerator(500,10);
      bsg.evolveGraph(500);
      DNVGraph graph = bsg.create();
      graph.writeGraph("/Users/scarlettteng/dev/bs1000_5000graph.dnv");
    }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

  // GenerateHistogramOfConnectivity.class );

  public static void generateHistogram( String filename, boolean includeZeros, int level )
  {
    System.out.println( "Starting histogram generation of " + filename );
    DNVGraph graph = new DNVGraph( filename );
    HashMap<Integer, Integer> histogram = generateHistogram( graph, level );

    writeHistogram( filename, includeZeros, histogram );
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

    FileReader fr = new FileReader( filename );
    CSVReader reader = new CSVReader( fr );

    String[] line;
    DNVGraph yearGraph = null;
    DNVGraph totalGraph = new DNVGraph();
    String currentYear = "";

    while( ( line = reader.readNext() ) != null )
    {
      // printArray( line );
      if( line[0].trim().startsWith( "YEAR" ) )
      {
        writeGraphs( yearGraph, totalGraph );
        yearGraph = new DNVGraph();
        yearGraph.setName( line[0].trim() );
        currentYear = line[0].trim().substring( line[0].trim().indexOf( "YEAR" ) + 5 );
      }
      else if( ( line.length == 1 && line[0].trim().equals( "" ) ) || line.length == 0 )
      {
        // ignore empty lines
      }
      else
      {
        // Handle edge
        addEdge( line, yearGraph, currentYear, "" );
        addEdge( line, totalGraph, currentYear, currentYear + "   " );
      }
    }

    reader.close();
    fr.close();

    List<DNVNode> nodes = totalGraph.getNodes( 0 );
    for( DNVNode node : nodes )
    {
      System.out.println( node.getLabel() );
    }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

    float size = Math.max( GraphFunctions.getGraphWidth( nodes, false ), width );
    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

    // String file = "matrixKL.txt";
    // input = readMatrix( directory, file );
    // double [][] weights = generateRandomInput( numberOfNodes );
    int n = input[0].length; // number of data objects
    double[][] output = MDSJ.stressMinimization( input ); // apply MDS
    DNVGraph graph = generateGraph( input, n, output );
    graph.writeGraph( Settings.GRAPHS_PATH + "MDS_stressMinimization.dnv" );

    output = MDSJ.classicalScaling( input ); // apply MDS
    graph = generateGraph( input, n, output );
    graph.writeGraph( Settings.GRAPHS_PATH + "MDS_classicalMDS.dnv" );

    float width = GraphFunctions.getGraphWidth( graph, 0, false );

    new RandomLayout().runLayout( graph, 0, width );
    new FruchtermanReingold().runLayout( width, width, graph, 0.01f, 0, false, false );
    graph.writeGraph( Settings.GRAPHS_PATH + "MDS_FR.dnv" );
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

   *            the output
   * @return the dNV graph
   */
  private static DNVGraph generateGraph( double[][] input, int n, double[][] output )
  {
    DNVGraph graph = new DNVGraph();
    for( int i = 0; i < n; i++ )
    { // output all coordinates
      DNVNode node = new DNVNode( graph );
      node.setPosition( (float)output[0][i], (float)output[1][i] );
      node.setColor( 0.3f, 0.7f, 1 );
      node.setLabel( "" + i );
      node.setBbId( "" + i );
      graph.addNode( 0, node );
    }
    for( int i = 0; i < input.length; i++ )
    {
      for( int j = 0; j < i; j++ )
      {
        DNVEdge edge = new DNVEdge( graph );
        DNVNode from = (DNVNode)graph.getNodeByBbId( "" + i );
        DNVNode to = (DNVNode)graph.getNodeByBbId( "" + j );
        edge.setFrom( from );
        edge.setTo( to );
        edge.setLabel( "" + Math.round( 100.0 * input[i][j] ) / 100.0 );
        edge.setRestingDistance( (float)input[i][j] );
        edge.setK( 1 );
        graph.addNode( 0, edge );
      }
    }
    return graph;
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

    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();
      to = line.substring( line.indexOf( "\t" ) + 2 ).trim();
      fromNode = (DNVNode)getNode( from, graph );
      toNode = (DNVNode)getNode( to, graph );
      edge = new DNVEdge( graph );
      edge.setFrom( fromNode );
      edge.setTo( toNode );
      edge.setDirectional( true );
      graph.addNode( 0, edge );
    }

    new FruchtermanReingold().runLayout( 100, 100, graph, 0.1f, 0, false, false );
    return graph;
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

   * @throws IOException
   *             Signals that an I/O exception has occurred.
   */
  public static void main( String args[] ) throws IOException
  {
    DNVGraph graph = convert( Settings.GRAPHS_PATH + "dep.csv" );
    graph.writeGraph( Settings.GRAPHS_PATH + "dep.dnv" );
  }
View Full Code Here

Examples of net.wigis.graph.dnv.DNVGraph

    {
      outputFileName += "WithFriendEdges";
    }
    outputFileName += ".dnv";
    List<String> dnvFiles = readFileToList( fileListFile );
    DNVGraph graph = new DNVGraph();
   
    for( String filename : dnvFiles )
    {
      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() );
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.