Graph
- class compas.datastructures.Graph[source]
Bases:
Datastructure
Base graph data structure for describing the topological relationships between nodes connected by edges.
- Parameters:
- default_node_attributesdict[str, Any], optional
Default values for node attributes.
- default_edge_attributesdict[str, Any], optional
Default values for edge attributes.
- **kwargsdict, optional
Additional keyword arguments are passed to the base class, and will be stored in the
attributes
attribute.
See also
- Attributes:
- default_node_attributesdict[str, Any]
dictionary containing default values for the attributes of nodes. It is recommended to add a default to this dictionary using
update_default_node_attributes()
for every node attribute used in the data structure.- default_edge_attributesdict[str, Any]
dictionary containing default values for the attributes of edges. It is recommended to add a default to this dictionary using
update_default_edge_attributes()
for every edge attribute used in the data structure.
Methods
Add an edge and specify its attributes.
Add a node and specify its attributes (optional).
Clear all the network data.
Return the edges connected to a node.
Return the number of neighbors of a node.
Return the numer of incoming neighbors of a node.
Return the number of outgoing neighbors of a node.
Delete an edge from the network.
Delete a node from the graph.
Get or set an attribute of an edge.
Get or set multiple attributes of an edge.
Returns a dictionary that maps edge identifiers (i.e.
Get the identifiers of a set of random edges.
Iterate over the edges of the network.
Get or set an attribute of multiple edges.
Get or set multiple attributes of multiple edges.
Get edges for which a certain condition or set of conditions is true.
Get edges for which a certain condition or set of conditions is true using a lambda function.
Construct an object of this type from the provided data.
Create a new graph instance from information about the edges.
Create a new graph instance from a NetworkX DiGraph instance.
Verify if the network contains a specific edge.
Verify if a specific node is present in the network.
Returns a dictionary that maps edges in a list to the corresponding vertex identifier pairs.
Returns a dictionary that maps the indices of a node list to keys in a node dictionary.
Verify if a node is a leaf.
Verify if a specific node is connected.
Return all leaves of the network.
Return the nodes in the neighborhood of a node.
Return the neighbors of a node.
Return the incoming neighbors of a node.
Return the outgoing neighbors of a node.
Get or set an attribute of a node.
Get or set multiple attributes of a node.
Returns a dictionary that maps node identifiers to their corresponding index in a node list or array.
Get a list of identifiers of a random set of n nodes.
Iterate over the nodes of the network.
Get or set an attribute of multiple nodes.
Get or set multiple attributes of multiple nodes.
Get nodes for which a certain condition or set of conditions is true.
Get nodes for which a certain condition or set of conditions is true using a lambda function.
Compute the number of edges of the graph.
Compute the number of nodes of the graph.
Return a summary of the graph.
Create a new NetworkX graph instance from a graph.
Unset the attribute of an edge.
Unset the attribute of a node.
Update the default edge attributes.
Update the default edge attributes.
Update the default node attributes.
Update the default node attributes.
Inherited Methods
Converts the instance to a string.
Make an independent copy of the data object.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Validate the data against the object's data schema.