mis.shared.graphs
Classes
-
BaseWeightPicker — Utility class to pick the weight of a node.
Functions
-
closed_neighborhood — Return the list of closed neighbours of a node.
-
is_independent — Checks if the node set is an independent set (no edges between them).
-
remove_neighborhood — Removes a node and all its neighbors from the graph.
Bases : ABC
Utility class to pick the weight of a node.
Unweighted implementations optimize the methods into trivial operations.
Methods
-
node_weight — Get the weight of a node.
-
set_node_weight — Set the weight of a node.
-
node_delta — Apply a delta to the weight of a node.
-
subgraph_weight — Get the weight of a subraph.
-
for_weighting — Pick a cost picker for an objective.
Get the weight of a node.
For a weighted cost picker, this returns attribute weight
of the node,
or 1. if the node doesn't specify a weight
.
For an unweighted cost picker, this always returns 1.
Raises
-
NotImplementedError
Set the weight of a node.
For a weighted cost picker, this returns attribute weight
of the node,
or 1. if the node doesn't specify a weight
.
For an unweighted cost picker, raise an error.
Raises
-
NotImplementedError
Apply a delta to the weight of a node.
Raises an error in an unweighted cost picker.
Raises
-
NotImplementedError
Get the weight of a subraph.
See node_weight
for the definition of weight.
For an unweighted cost picker, this always returns len(nodes)
.
Raises
-
NotImplementedError
Pick a cost picker for an objective.
Raises
-
NotImplementedError
Return the list of closed neighbours of a node.
Checks if the node set is an independent set (no edges between them).
Parameters
-
graph : nx.Graph — The graph to check.
-
nodes : list[int] — The set of nodes.
Returns
-
bool — True if independent, False otherwise.
Removes a node and all its neighbors from the graph.
Parameters
-
graph : nx.Graph — The graph to modify.
-
nodes : list[int] — List of nodes to remove.
Returns
-
nx.Graph — The reduced graph.