-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
Adjacency matrix for only some vertices #2196
Comments
This has the same snag as subset betweenness: partially overlapping vertex selections for the undirected case need special care. |
Does it? I believe this is a simple matrix subsetting operation. I.e. the result should be the same as taking only some rows and only some columns in the adjacency matrix. The fact that in the undirected partially overlapping case some connections will appear twice (below and above diagonal) and some once should not be a problem here. Let me know if I misunderstood something. |
Doesn't that take an unnecessary amount of time? For the |
I didn't mean that it should be implemented by subsetting the complete matrix. That makes no sense, as there would be no performance gain in using this function. I simply meant to describe the expected result.
I see what you mean. How about this?
I think this gives the correct result both for directed and undirected graphs. However, its performance characteristics are not invariant to the exchange of An alternative implementation will not construct We already have such sorted intersection functions,
Maybe we should have helper functions for union, intersection, difference, symmetric difference for sorted integer lists. I suspect that one of these two approaches should be faster than starting with a source and target vertex ID, then getting the edges inbetween. But this is difficult to predict ... What do you think @GroteGnoom ? |
These are the two common ways to intersect vertex sets, and I'm never sure which is faster, or under what conditions each is faster. E.g. |
Lets use an example to clear things up. I think the simplest case where we have problems is a 3-vertex full graph with no loops, from = [0,1,2], to = [0,1]. The full
we have 3 selected edges: First,
And this is
... I'll have to think a bit. |
For this application, there should be no |
I think that just solves everything 🙂 I think this also shows the betweenness_subset problem in matrix form: neither the upper triangle or lower triangle necessarily has all the selected edges, and the whole matrix sometimes has an edge twice, sometimes once. |
What is the feature or improvement you would like to see?
Currently there is
igraph_get_adjacency(_sparse)()
to construct the adjacency matrix of a graph. There is alsoigraph_get_incidence()
for a bipartite incidence matrix.I propose a generalization of both where the vertices corresponding to the matrix rows/column can be specified:
This would generate the submatrix corresponding the specified row-vertices and column-vertices.
There should be a sparse version as well.
Use cases for the feature
One of the purposes of this function would be to offer better performance and better memory usage than generating the entire adjacency matrix first then subsetting it.
References
—
The text was updated successfully, but these errors were encountered: