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

Edge between two edges (or node and edge), edges inside nodes/edges (recursive encapsulation) #1217

Closed
Konard opened this issue Jan 10, 2016 · 16 comments

Comments

@Konard
Copy link

Konard commented Jan 10, 2016

I`m working on project (https://github.com/Konard/LinksPlatform) that uses associative model of data.
For example this platform (as database) allows to store egdes between edges. And there is no difference between edges and nodes, all are links (pairs of references to other two links - source & target). Also because link consists of two links this creates a fractal which can be used to store sequences or entire graphs (networks) insite one link.

So my question is it possible to visualize something like this using cytoscape.js ? And if not, is it easy to extend/modify cytoscape.js for that task?

Node to node, node to edge:
links

Node to node, node to edge, edge to edge:
links-edge-to-edge

Sequence, fractal, recursive encapsulation:
12

I actually tried to change example (http://jsbin.com/gist/5b192c88616af2f75344) like this:

edges: [
      { data: { id: 'ad', source: 'a', target: 'd' } },
      { data: { id: 'eb', source: 'e', target: 'b' } },
      { data: { id: 'adeb', source: 'ad', target: 'eb' } } // Added this edge
    ]

But added edge didn`t show up.

@maxkfranz
Copy link
Member

This is a duplicate of #959

@maxkfranz
Copy link
Member

You would have to create intermediary nodes to simulate hyperedges, as hyperedges are not supported natively yet. It's not such a simple feature to implement, because it would affect large parts of the API -- like algorithms, traversing, etc.

@Konard
Copy link
Author

Konard commented Jan 11, 2016

This is not a duplicate, because described above does not match definition of hyperedge direclty. Hyperedge is N to N connection, edge is 1 to 1. Link is also 1 to 1 connection, but difference is that each one (of these 1s) are also links (or edges), and there is no separate verticies type. For example link that starts from itself and ends with itself is a point, or actually a verticle. The actual needed feature is to allow source and target of edges to reference other edges (not only nodes).

https://en.wikipedia.org/wiki/Associative_model_of_data (here vertices/nodes/items coexist with links/edges).

@maxkfranz
Copy link
Member

My mistake. If you want not hyperedges but edge-edge edges, I'm not sure whether that would make sense. One of the premises of graph theory is that edges connect nodes. Whereas algorithms and traversal etc. can be made to make sense with hyperedges, my intuition is that edge-edge edges could not.

@maxkfranz maxkfranz reopened this Jan 11, 2016
@Konard
Copy link
Author

Konard commented Jan 12, 2016

One of the premises of graph theory is that edges connect nodes.

This is still true here. However if also an edge can connect edges then new possibilities for algorithms are open. One way to use this is to get an ability to describe ordered set (or sequence).

edges: [
      { data: { id: 'ad', source: 'a', target: 'd' } },
      { data: { id: 'eb', source: 'e', target: 'b' } },
      { data: { id: 'adeb', source: 'ad', target: 'eb' } } // Added this edge
    ]

If we take this example, we can interpret 'adeb' edge as tree of edges ((a -> d) (e -> b)), and at the same time as sequence of nodes (a -> d -> e -> b) or just "adeb" (string), if 'a', 'd', 'e' & 'b' nodes represent corresponding letters/symbols itself. It can be an N-gram of words (not only letters). For example a sentence (builded with nodes).

All previous logic with nodes still ok. And new can be added. I`m not sure it should be so difficult as hyperedges implementation. Because cytoscape already has an ability to click on edges, name edges. So the addition is, to render edges, that starts from center(middle) of one edge to center(middle) of other edge. May be it can be done as a plugin or switch/option that can be turned on or off.

Other visualizations (from book by SIMON WILLIAMS, "THE ASSOCIATIVE
MODEL OF DATA", http://www.sentences.com/docs/other_docs/AMD.pdf ):
2016-01-12 16-34-00
2016-01-12 16-34-09

Here is an example of semantic type system, that uses links/edges as node/pairs to continue an English sentence (fact) about some real world event.

@maxkfranz
Copy link
Member

I've spoken to others in the Cytoscape team about this. This would be far more difficult than the hyperedges implementation. As I said before, a basic premise of graph theory is that edges connect only nodes. Allowing edges to connect to edges breaks that premise, and completely breaks the model.

Cytoscape.js is not just a visualisation tool, it has a sophisticated graph theoretic model and accompanying algorithms. We can't break 90%+ of the functionality of the library to accommodate a single non-graph-theory usecase.

Your examples are database entity-relationship models. N-ary relationships are represented by entities, in databases and in your diagramme. Similarly, you should be using separate nodes to represent n-ary relationships if you want to use Cytoscape.js. You can do this in your app-level code or you can create an extension.

If you can point us toward reputable journal published papers that define edge-edge edges in graph theory, then perhaps we can revisit this.

For now, I'm closing this and you can use intermediary nodes.

Thanks for your feedback

@maxkfranz
Copy link
Member

Those are ER/database models, not graph theoretic models.

@Konard
Copy link
Author

Konard commented Jan 13, 2016

Ok there are other possible solutions:

  1. Possibility to remove arrow from edge (just a straight line between nodes) So the edge is always an node with exacly two edges (one in and one out), and both edges should be synchronized (continue the same path).
  2. Possibility to embed another cytoscape graph inside the node. So that node will have inner structure. For example to embed a small visualization with two nodes and one edge inside other node.

Can you please point out are these options possible with cytoscape?

For now, I'm closing this and you can use intermediary nodes.

Or.. What exactly do you mean by intermediary nodes?

@maxkfranz
Copy link
Member

You should be able to do (1) with an intermediary node between the edges so that the edge-edge edge points towards the intermediary node. (2) is just compound nodes.

@Konard
Copy link
Author

Konard commented Jan 15, 2016

@Konard
Copy link
Author

Konard commented Mar 25, 2016

http://gojs.net/latest/samples/linksToLinks.html (implementation at go.js)

@maxkfranz
Copy link
Member

Go.js is a generic charting lib, Cytoscape.js is for graph theory

As far as I'm aware, there is no concept of edge-edge edges in graph theory.

@dhakehurst
Copy link

I too would like this option.
intermediate nodes are not a solution due to layout.

@jri
Copy link

jri commented Dec 14, 2018

@maxkfranz talks about graph model.
@Konard talks about associative model, which is inherently different.
Although I'm a Cytoscape.js user myself and looking for a visualization/interaction solution for the associative model too, Cytoscape.js might not be the proper foundation for that.

@jri
Copy link

jri commented Jan 2, 2019

I've created a Cytoscape extension that allows edges to be connected to other edges, according to the Associative Model of Data:
https://github.com/jri/cytoscape-edge-connections

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

4 participants