Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

How to draw edges of a graph with different colors according to their weights with neovis.js (Neo4j)?

Ask Question

I have a graph with weighted edges in Neo4j. I visualized it with neovis.js library as shown in the attached figure. Currently, all edges have same color. In the next step I need to assign colors to edges such that every group (Cluster or Community) of edges has a different color based on a predefined property of the edges (the property is defined for edges not vertices).

My graph node and relationship are stored as follows:

Node: Vertex (index, name), Ex: (42, "Vertex 23")

Relationship: EDGE (index, count, group), Ex: (12, 42, 0), (24, 230, 1)

(:Vertex)-[:EDGE]->(:Vertex)

Here is my code for creating the graph:

<script src="https://rawgit.com/neo4j-contrib/neovis.js/master/dist/neovis.js"></script> <script> function draw() { var config = { container_id: "viz", server_url: "bolt://localhost:7687", server_user: "***", server_password: "***", labels: { "Vertex": { caption: "name" relationships: { "EDGE": { caption: false, thickness: "count" initial_cypher: "MATCH p=()-[:RELATIONSHIP]->() RETURN p" var viz = new NeoVis.default(config); viz.render(); </script> <body onload="draw()"> <div id="viz"></div> </body> </html>

It would be good if I can map a specific color to each group as well. Let's say group is a binary property, so I want something like this:

relationships: { "EDGE": { caption: false, thickness: "count" color: "group" {0: red, 1: green} The problem is that the neovis.js library does not provide an easy way to do this. So it is easier to use together vis.js network ( visjs.org/docs/network ) and neo4j-javascript-driver ( github.com/neo4j/neo4j-javascript-driver ) without using this library. stdob-- Dec 5, 2018 at 22:33

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .