-
Notifications
You must be signed in to change notification settings - Fork 79
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
ENH: add subgraph method to Graph to get subsets #640
Conversation
islands = np.setdiff1d(ids, heads) | ||
islands = pd.Index(ids).difference(pd.Index(heads)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This turned out to be several orders of magnitude faster for large string indices.
Codecov Report
@@ Coverage Diff @@
## main #640 +/- ##
=====================================
Coverage 83.9% 83.9%
=====================================
Files 139 139
Lines 14970 14976 +6
=====================================
+ Hits 12562 12569 +7
+ Misses 2408 2407 -1
|
cool. I wonder if we can use this to enhance pysal/esda#259 as discussed over there (e.g by computing the largest range first, then successively cutting down the graph). Seems like you'd still need a tree query to get the indices though? |
I don't think so. This aims to create a subgraph based on a subset of focals. In correlogram, you need to keep the same focals but cut their neighbors. What you could doe once #635 is in is something like this: for i in distances:
adj = graph_w_distance.adjacency.copy()
adj[adj > i] = 0
smaller_graph = graph.Graph(adj, is_sorted=True).transform("r")
# compute stats using smaller_graph This assumes that edit: you could eventually call |
I have found myself in a need to create subsets of a large graph covering only specific portions of my geometries. Hence I have developed a method to create a subgraph since making a subset of adjacency and passing that to a constructor discards isolates.