Vis Network: Get the data about the Edges [fromId, toId] #2557

Open
FilipQL opened this Issue Jan 9, 2017 · 0 comments

Projects

None yet

2 participants

@FilipQL
FilipQL commented Jan 9, 2017

I am using Vis Network and the manipulation module is enabled so I can draw (add/delete) nodes & edges. After I finish with drawing nodes and edges, I would like to get information about what is drawn - about the current graph. Specifically, I would like to get information about all edges that are in the current graph, in the format like this:

[
        {from: 1, to: 3},
        {from: 1, to: 2},
        {from: 2, to: 4},
        {from: 2, to: 5}
]

So, to be clear, when we want to generate a graph - we need to pass edges as the following array:

...
    var nodes = [
        {id: 1, label: 'Node 1'},
        {id: 2, label: 'Node 2'},
        {id: 3, label: 'Node 3'},
        {id: 4, label: 'Node 4'},
        {id: 5, label: 'Node 5'}
    ];

    // create an array with edges
    var edges = [
        {from: 1, to: 3},
        {from: 1, to: 2},
        {from: 2, to: 4},
        {from: 2, to: 5}
    ];
...
    // provide the data in the vis format
    var data = {
        nodes: nodes,
        edges: edges
    };
...
var network = new vis.Network(container, data, options);

What I want is the opposite: First we draw the graph (we add nodes, edges...) - and after we finish that, we want to get info about the edges (by info I mean an array with edges that can be later re-used to draw the same graph, for example:

[
        {from: 1, to: 3},
        {from: 1, to: 2},
        {from: 2, to: 4},
        {from: 2, to: 5}
]

). How to do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment