vis.js multiple group membership - vis.js

Is it possible for a node to belong in multiple groups? Can there be multiple links between two nodes? Further can links belong to groups?
Example:
An ethernet switch has multiple VLANs (Groups?).
Each switch will have links for each VLAN.
A switch (node) might have multiple links to another switch (node), but only one per VLAN (group). In reality multiple links could exist, but this could be represented by link strengths.
The goal is to be able to interactively analyze how switches connect together on a per vlan basis. Is there a straight forward way to do this? The documentation seemed to suggest a node can only belong to one group.

To answer your first question (multiple group membership), it appears nodes can belong only to one group. I haven't found any mention saying otherwise.
As for the second question (more links between two nodes), yes, there can:
{from: 1, to: 3},
{from: 1, to: 3},
http://screencloud.net/v/kHGBf
As for the third question (can edges belong to groups): they can't. A group attribute has no effect, even if present.

Related

Get nodes adjacent to child node in Gremlin

I'm fairly new to Gremlin and I'm trying to query a graph starting at my vertex Customer, which is related to various nodes amongst which is the Account node. And so, I want to retrieve all nodes related to the Customer node + all nodes related to the Account node connected to it.
As you can see in the image, my Customer node is related to the account node via the has_account edge. I would like to get all the nodes adjacent to that account node.
Customer node
As I said, I'm fairly new to neptune so what I've tried aside from the most basic visualizations is:
g.V('id').outE().inV().outE().inV().path()
And that gives me the nodes adjacent to the Account node but ommits the other adjacent nodes to the Customer node. I've also tried some other groupings and mappings but I can't seem to make it work.
In the query you wrote above, you are starting out a vertex id and then traversing to all of its connections (the first outE().inV(), and then the connections of the connections (the second outE().inV()). If a connection does not have any connections, then it will be filtered out.
If you would like to return both the 1st and optionally 2nd connections, then I would look at using the optional() step for the 2nd+ level connections that may or may not exist like this:
g.V('id').outE().inV().optional(outE().inV()).path()

How do you group social network nodes?

A graph is made up of nodes/vertexes connected by edges/arcs. Multiple sub groups of nodes often exist (colored below). These can be people in a social network, items and purchase records, travel data, or many other things.
How do you:
Split the nodes into groups based on edges
find the leader (most connected node) in each subgroup?
To answer your first question, you can use one of several community structure algorithms, such as:
Minimum-cut method
Hierarchical clustering
Girvan–Newman algorithm
Modularity maximization
Among others.
As for your second question, once you know the members within a group you can rank them by number of connections.

Javafx Nodes only able to be in one Group?

I am not sure if this is a bug or not or just my JavaFX program but I am trying to add nodes to several Groups (only one of which is added to the scene) and encountering an oddity where the node will automatically remove itself from the previous group when I add it to another group.
I can't find any documentation on this talking about objects only being able to belong to one group, so was wondering whether its a bug or meant to be? I was hoping to use several groups to collect items in different groupings so that I can apply high level effects such as MouseTransparency, Opacity etc to whole groups on a on/off basis rather than iterate through items as a list where some child objects already have things like MouseTransparency disabled (therefore I don't want to turn it back on for items that originally did not have MouseTransparency - a feature that was handy by adding them to groups).
I note that you can add groups as a child to other groups. I have tried solving my problem by having this, groups nested under the main visually shown Group, but had to abandon that as I could not do a comparator sort on all the wholes if they are contained within sub-groups as I could then only sort either within a sub-group or sort the groups as groups within the main Group, rather than sorting all the nodes across all sub-groups.
Thanks
Refer to the Node documentation:
If a program adds a child node to a Parent (including Group, Region, etc) and that node is already a child of a different Parent or the root of a Scene, the node is automatically (and silently) removed from its former parent.

How to add multiple joinCondition in vis.js while clustering

I am using vis.js for network diagramming, I need to cluster some nodes.
For Example: create new cluster when a node property is 'aaa' (Suppose two nodes has 'aaa' they will create cluster).
Again create new cluster when a node property is 'bbb' (Suppose two nodes has 'bbb' they will create another cluster).
I have two problems:
1) I don't want to hard-code 'aaa' or 'bbb'.
2) I don't want to create multiple clusterOptionsByData object and invoke network.cluster(clusterOptionsByData) multiple times.
Is there any way to pass multiple joinconditions while clustering in vis.js?
I'm the developer of the visjs network. The answer to 2) is no.
What is the use case of not wanting to call the method twice? You can construct your own join condition based on variables and pass that into the cluster method. You don't need to hardcore anything.
Every cluster call makes one cluster. Multiple join conditions do not make sense. It's up to you to come up with a good join condition that covers all your cases.
Next time you have a question, post it on our github issues page. We get email updates on these so we'd be able to help you quicker.
Cheers

Can a graph database edge have multiple starting nodes?

I am designing a graph database for eligibility rules. Some eligibility rules require that a user select 2 particular products (Product A and Product B) to qualify for Product C.
Is it possible to create a graph edge with 2 starting nodes?
I would think this would break what I think is the fundamental building block of a graph db - its adjacency list. But if this was possible, it would be very powerful for my application.
Update 6/16
More specifically, I'm looking to create a directed edge with 2 starting nodes, and 1 ending node. So, in biz rules terms: IF Node=A AND Node=B THEN Node=C. The real world relationship is this: If customer buys Product A and Product B, then customer qualifies for Product C.
Usually, to model a hypergraph in Neo4j, you end up creating an intermediate "group node" that connects all of the nodes you want to connect, then bridging off of that node to the other node. It's not a true hypergraph, but rather a representation of a hypergraph using the tools provided.
Here's an example:
http://www.markhneedham.com/blog/2013/10/22/neo4j-modelling-hyper-edges-in-a-property-graph/
Yes you can have multiple starting nodes in Neo4j, not sure about other graph db.
START a=node(0), b=node(1)
RETURN a,b
You should refer to http://docs.neo4j.org/chunked/stable/query-start.html for more details. Starting from Neo4j 2.0 start node is optional, Cypher will try and infer starting points from your query based on label and where clause.
Edit
I have edited the answer based on the updated question. What you need is a hypergraph. As Wes Freeman mentioned, to model a hypergraph Neo4j you will need to create an intermediate node that connects your other two nodes and the the third node. In you scenario a user will have a PURCHASED relationship with the two products(A and B) kinda like (:User {Id: 1})-[:PURCHASED]->(:Product {Name:A}). Then you will have to create an intermediate node like ProductQualifier (I am very bad at naming things) having a relationship from user like (:User {Id:1})-[:QUALIFIES]->(:ProductQualifier {Id:1}). The Product qualifier will then have 3 relations, two to Product A and B respectively and a third to Product C,
(:Product {Name: 'B'})<-[:HAS]-(:ProductQualifier {Id:1})-[:HAS]->(:Product {Name: 'A'})
(ProductQualifier {Id:1}-[:ELIGIBLE]->(:Product {Name: 'C'})
This ought to do what you want.
A second approach that you can take is use a database that inherently supports hypergraphs, something like Hypergraphdb, thus discarding the burden of creating extra node. I haven't had any occasion to use it though I wanted to try it out for quite some time, so I don't know in much details about its API's or its limitations, however it is fairly well known graph database.
Note: As mentioned I am very bad at naming things. You should probably change the label names to more suitable to your business model.

Resources