-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
indexOfId and adjacency matrix #3047
Comments
You have the start to a great idea here. It would make a nice extension. Matrices are useful for calculations, and so you’d need to support one or many popular output formats (e.g. glMatrix, Math.js) so that the matrices are easily computable. Matrices are more useful when they also can support scores instead of just binary adjacency values, so that would be a great option within your extension. You should use your own indexing scheme for the nodes in the matrix — for general reasons and also because extensions consumers will tend to want specific, custom orderings anyway. Be clear about the features and limitations of your extension in the readme. For instance, how will you handle multigraphs in the matrices? How will you handle compound node hierarchies? Looking forward to seeing your extension! |
Thanks, I am working on a small educational project about graphs from a maths point of view. We will maybe create an extension(s) with some invariants (girth, diameter...) and utils (adjacency matrix). To change the index ordering using To be clear: There is no plan to document the function |
There are definitely cases where it won't work -- and in confusing, surprising ways. It shouldn't be public. It's used internally in the core library only with strict preconditions. It would probably be better if we didn't use Good luck with your project. Maybe link it in #914 when it's ready, if you like. |
Ok, thanks Max. |
Description of new feature
Add a method to obtain the adjacency matrix of a graph.
Ideally, add a method to build a graph from its adjacency matrix.
Document properly the function
cy.nodes().indexOfId()
Motivation for new feature
While it is not difficult to create the adjacency matrix from a cytoscape graph instance, it seems a handy method to be supported by default.
Looking for "adjacency" in the repository, it is already implemented inside other functions, for instance:
https://github.com/cytoscape/cytoscape.js/blob/e6541de603f5714f572238573ea06ef17503282b/src/collection/algorithms/page-rank.js
In that example, it is used the method
cy.nodes().indexOfId("str")
which gives you the index of an element with idstr
(in the array cy.nodes()[] ). This function works perfectly, but it is not documented in the cytoscape page.indexOfId()
?cy.nodes()[]
or is there any function that alters that ordering unexpectedly? (it is expected when one removes a node, for instance)Describe your use case for this new feature.
The function indexOfId is needed to create the adjacency matrix, and since it exists, it would be easier to use it instead of adding another indexing.
There are many use cases for the adjacency matrix.
The text was updated successfully, but these errors were encountered: