qbiocode.apps.quvine.data.subgraph module#
Summary#
Functions:
Expand neighborhood around roots up to given hop radius using adjacency dict access. |
|
Fill remaining budget preferring nodes adjacent to keep; fall back to random. |
|
Materialize an induced subgraph without using G.subgraph(...) to avoid view contamination. |
|
Return a fully materialized undirected simple nx.Graph (no views, no DiGraph internals). |
|
Subsample nodes while preserving a protected set. |
Reference#
- materialize_undirected_simple_graph(G)[source]#
Return a fully materialized undirected simple nx.Graph (no views, no DiGraph internals). This avoids traversal issues from graph views and preserves node/edge attributes.
- Return type:
Graph
- induce_subgraph_by_nodes(G, nodes)[source]#
Materialize an induced subgraph without using G.subgraph(…) to avoid view contamination.
- Return type:
Graph
- expand_neighborhood(G, roots, radius)[source]#
Expand neighborhood around roots up to given hop radius using adjacency dict access. No G.neighbors() calls;
- Return type:
Set[Hashable]
- fill_random_until_budget(G, keep, max_nodes, rng)[source]#
Fill remaining budget preferring nodes adjacent to keep; fall back to random.
- fill_degree_matched_until_budget(G, keep, max_nodes, rng, *, reference_nodes=None)[source]#
- Return type:
Set[Hashable]
- subsample_nodes_with_protected(G, protected, max_nodes, rng, *, expand_radius=None, require_full_budget=True, degree_matched_fill=False, degree_matched_trim=False, degree_reference_nodes=None)[source]#
Subsample nodes while preserving a protected set.
Workflow:
keep all protected nodes
optionally expand by hop radius around them
if expansion exceeds budget, optionally trim in a degree-matched way
fill remaining budget either with neighborhood/random expansion or with degree-matched sampling from the remaining graph
- Return type:
Graph