Skip to content

Results are limited to Maximum Independent Set v0.2.3

Product news
You are reading Maximum Independent Set v0.2.3, an older version of this documentation. Go to the latest version (v0.3.2)

mis.shared.graphs

module
mis.shared.graphs

Classes

Functions

class
BaseWeightPicker ()

Bases : ABC

Utility class to pick the weight of a node.

Unweighted implementations optimize the methods into trivial operations.

Methods

classmethod
node_weight (graph: nx.Graph, node: int) → float

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

classmethod
set_node_weight (graph: nx.Graph, node: int, weight: float) → None

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

classmethod
node_delta (graph: nx.Graph, node: int, delta: float) → float

Apply a delta to the weight of a node.

Raises an error in an unweighted cost picker.

Raises

  • NotImplementedError

classmethod
subgraph_weight (graph: nx.Graph, nodes: typing.Iterable[int]) → float

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

classmethod
for_weighting (weighting: Weighting) → type[BaseWeightPicker]

Pick a cost picker for an objective.

class
WeightedPicker ()

classmethod
node_weight (graph: nx.Graph, node: int) → float

classmethod
set_node_weight (graph: nx.Graph, node: int, weight: float) → None

classmethod
subgraph_weight (graph: nx.Graph, nodes: typing.Iterable[int]) → float

class
UnweightedPicker ()

classmethod
node_weight (graph: nx.Graph, node: int) → float

classmethod
set_node_weight (graph: nx.Graph, node: int, weight: float) → None

Raises

  • NotImplementedError

classmethod
subgraph_weight (graph: nx.Graph, nodes: typing.Iterable[int]) → float

closed_neighborhood (graph: nx.Graph, node: int) → list[int]

Return the list of closed neighbours of a node.

is_independent (graph: nx.Graph, nodes: list[int]) → bool

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.

remove_neighborhood (graph: nx.Graph, nodes: list[int]) → nx.Graph

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.