| | |
- builtins.object
-
- OrderedPartition
- Partition
class OrderedPartition(builtins.object) |
| |
OrderedPartition(partitions: List[structure_learning.data_structures.partition.Partition])
Represents an ordered collection of Partition objects. |
| |
Methods defined here:
- __init__(self, partitions: List[structure_learning.data_structures.partition.Partition])
- Initialize with a list of Partition objects.
Args:
partitions (list): List of Partition objects.
- __str__(self)
- Return a string representation of the OrderedPartition.
- add_node_to_partition(self, part_indx: int, node: str)
- Add a node to the partition at `part_indx`.
Args:
part_indx (int): Partition index.
node (str): Node label.
- copy(self)
- Return a deep copy of the OrderedPartition.
- find_node(self, node_label)
- Return the index of the partition containing `node_label`, or None if not found.
Args:
node_label (str): Node label to search for.
- get_all_nodes(self)
- Return a set of all nodes in all partitions.
- get_all_nodes_adj_left(self, indx)
- Return all nodes in the partition at index `indx-1`.
Args:
indx (int): Index.
- get_all_nodes_adj_right(self, indx)
- Return all nodes in the partition at index `indx`.
Args:
indx (int): Index.
- get_all_nodes_from_left(self, indx)
- Return all nodes from the start up to (but not including) index `indx`.
Args:
indx (int): End index.
- get_all_nodes_from_right(self, indx)
- Return all nodes from partition at index `indx` to the end.
Args:
indx (int): Start index.
- get_partition_by_indx(self, index)
- Return the partition at the given index.
Args:
index (int): Partition index.
- get_partitions(self)
- Return the list of Partition objects.
- info(self)
- Print information about all partitions.
- insert_partition(self, part_id: int, nodes: set)
- Insert a new partition at `part_id` with the given nodes.
Args:
part_id (int): Index to insert at.
nodes (set): Nodes for the new partition.
- join_partition(self, part_id: int)
- Join the partition at `part_id` with its left neighbor.
Args:
part_id (int): Partition index.
- plot(self, fig_size=(2.7, 6), title='Ordered Partition')
- Visualize all partitions side by side.
Args:
fig_size (tuple): Figure size for matplotlib.
title (str): Title for the plot.
- print_partitions(self)
- Return a string with all partitions.
- remove_empty_partitions(self)
- Remove all empty partitions from the collection.
- remove_node_from_partition(self, part_id: int, node: str)
- Remove a node from the partition at `part_id`.
Args:
part_id (int): Partition index.
node (str): Node label.
- remove_partition(self, part_id)
- Remove the partition at `part_id`.
Args:
part_id (int): Partition index.
- replace_partition(self, new_partition: structure_learning.data_structures.partition.Partition, index: int)
- Replace the partition at `index` with `new_partition`.
Args:
new_partition (Partition): Replacement partition.
index (int): Index to replace.
- save(self, filename: str)
- Saves the Graph object to a file.
Parameters:
filename (str): Path to the output file.
- to_party_permy_posy(self)
- Return the party, permy, and posy representations of the partition.
- update_IDs(self)
- Update the IDs of all partitions to be consecutive starting from 0.
Class methods defined here:
- from_graph(g: structure_learning.data_structures.graph.Graph)
- Create an OrderedPartition from a Graph object.
Args:
g (Graph): Graph instance.
- from_numpy(incidence: numpy.ndarray, node_labels: list)
- Create an OrderedPartition from an incidence matrix and node labels.
Args:
incidence (np.ndarray): Incidence matrix.
node_labels (list): List of node labels.
- from_string(string: str)
- Create an OrderedPartition from a string representation.
Args:
string (str): String representation.
- load(filename: str)
- Loads a Graph object from a file.
Parameters:
filename (str): Path to the input file.
Returns:
Graph: Loaded Graph object.
Readonly properties defined here:
- all_nodes
- Return a set of all nodes in all partitions.
- size
- Return the number of partitions.
Data descriptors defined here:
- __dict__
- dictionary for instance variables
- __weakref__
- list of weak references to the object
- partitions
- Return the list of Partition objects.
|
class Partition(builtins.object) |
| |
Partition(ID: int, nodes: set)
Represents a single partition of nodes. |
| |
Methods defined here:
- __init__(self, ID: int, nodes: set)
- Initialize a Partition with an ID and a set of nodes.
Args:
ID (int): Partition identifier.
nodes (set): Set of node labels.
- __str__(self)
- Return a string representation of the partition.
- add_nodes(self, nodes: set)
- Add multiple nodes to the partition.
Args:
nodes (set): Set of node labels to add.
- add_single_node(self, node: str)
- Add a single node to the partition.
Args:
node (str): Node label to add.
- copy(self)
- Return a deep copy of the partition.
- get_ID(self)
- Return the partition's ID.
- info(self)
- Print information about the partition.
- plot(self, fig_size=(2.7, 6))
- Visualize the partition as a rectangle with nodes as circles.
Args:
fig_size (tuple): Figure size for matplotlib.
- remove_nodes(self, nodes: set)
- Remove multiple nodes from the partition.
Args:
nodes (set): Set of node labels to remove.
- remove_single_node(self, node: str)
- Remove a single node from the partition.
Args:
node (str): Node label to remove.
- replace_partition(self, new_partition)
- Replace the current partition with another partition.
Args:
new_partition (Partition): Partition to copy from.
- set_ID(self, ID)
- Set the partition's ID.
Args:
ID (int): New partition ID.
Readonly properties defined here:
- size
- Returns the number of nodes in the partition.
Data descriptors defined here:
- __dict__
- dictionary for instance variables
- __weakref__
- list of weak references to the object
- nodes
- Returns the set of nodes in the partition.
| |