src/javascript/lib/drawings/simple_graph.js
/**
     *  Creates a graph with random nodes and edges.
     *  Number of nodes and edges can be set with
     *  numNodes and numEdges.
     */
Creates a graph with random nodes and edges.
Number of nodes and edges can be set with
numNodes and numEdges.
Creates a graph with random nodes and edges . Number of nodes and edges can be set with numNodes and numEdges .
function createGraph() {
        var nodesDic = [];
        for (var i = 0; i < nodes.length; i++) {
            var node = new Node(nodes[i].id);
            graph.addNode(node);
            node.data.title = nodes[i].title;
            node.data.color = nodes[i].color;
            drawNode(node);
            nodesDic[nodes[i].id] = node;
        }
        for (var i = 0; i < edges.length; i++) {
            if (graph.addEdge(nodesDic[edges[i].src], nodesDic[edges[i].dst])) {
                drawEdge(nodesDic[edges[i].src], nodesDic[edges[i].dst]);
            }
        }
        that.layout_options.width = that.layout_options.width || 2000;
        that.layout_options.height = that.layout_options.height || 2000;
        that.layout_options.iterations = that.layout_options.iterations || 100000;
        that.layout_options.layout = that.layout_options.layout || that.layout;
        graph.layout = new Layout.ForceDirected(graph, that.layout_options);
        graph.layout.init();
        info_text.nodes = "Nodes " + graph.nodes.length;
        info_text.edges = "Edges " + graph.edges.length;
    }
function createGraph ( ) { var nodesDic = [ ] ; for ( var i = 0 ; i < nodes . length ; i ++ ) { var node = new Node ( nodes [ i ] . id ) ; graph . addNode ( node ) ; node . data . title = nodes [ i ] . title ; node . data . color = nodes [ i ] . color ; drawNode ( node ) ; nodesDic [ nodes [ i ] . id ] = node ; } for ( var i = 0 ; i < edges . length ; i ++ ) { if ( graph . addEdge ( nodesDic [ edges [ i ] . src ] , nodesDic [ edges [ i ] . dst ] ) ) { drawEdge ( nodesDic [ edges [ i ] . src ] , nodesDic [ edges [ i ] . dst ] ) ; } } that . layout_options . width = that . layout_options . width || 2000 ; that . layout_options . height = that . layout_options . height || 2000 ; that . layout_options . iterations = that . layout_options . iterations || 100000 ; that . layout_options . layout = that . layout_options . layout || that . layout ; graph . layout = new Layout . ForceDirected ( graph , that . layout_options ) ; graph . layout . init ( ) ; info_text . nodes = "Nodes " + graph . nodes . length ; info_text . edges = "Edges " + graph . edges . length ; }
Creates a graph with random nodes and edges.
Creates a graph with random nodes and edges .