Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I visualize MultiGraph? #73

Open
Lecanyu opened this issue Jan 19, 2018 · 0 comments
Open

How can I visualize MultiGraph? #73

Lecanyu opened this issue Jan 19, 2018 · 0 comments

Comments

@Lecanyu
Copy link

Lecanyu commented Jan 19, 2018

Hi,

I have tried to visualize simple graph. Everything looks good. However, how can I visualize multigraph?

Here is my sample code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Sample</title>
</head>
<body>
<div id="canvas"></div>

<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="js/jsnetworkx.js"></script>

<script type="text/javascript">
    var G = new jsnx.MultiGraph();

    G.addNodesFrom([1,2,3]);
    G.addEdgesFrom([[1,3],[1,3],[1,2],[1,2],[2,3],[2,3]]);
    console.log(G.edges());     // I can see 6 edges printed on console
    jsnx.draw(G, {
        element: '#canvas',
        withLabels: true,
        nodeStyle: {
            fill: function(d) {
                return d.data.color;
            }
        },
        labelStyle: {fill: 'white'},
        stickyDrag: true
    });
</script>
</body>
</html>

And the result is

image

How to draw multiple parallel edges between two nodes?

Any help will be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant