InteractionGraph

class compas_model.model.InteractionGraph(default_node_attributes=None, default_edge_attributes=None, name=None, **kwargs)

Bases: Graph

Class representing the interactions between elements in a model.

Parameters:
default_node_attributesdict, optional

The default attributes for nodes.

default_edge_attributesdict, optional

The default attributes for edges.

Notes

The main purpose of this class customisation is to modify the data serialisation behaviour of the graph in the context of element interaction modelling in a model.

Methods

copy

Make an independent copy of the data object.

edge_interactions

Get the element associated with the node.

interactions

Get the interactions in the graph.

node_element

Get the element associated with the node.

Inherited Methods

ToString

Converts the instance to a string.

aabb

Calculate the axis aligned bounding box of the graph.

add_edge

Add an edge and specify its attributes.

add_node

Add a node and specify its attributes (optional).

adjacency_matrix

Creates a node adjacency matrix from a Graph datastructure.

clear

Clear all the graph data.

complement

Generate the complement of a graph.

compute_aabb

Compute the axis-aligned bounding box of the datastructure.

compute_obb

Compute the oriented bounding box of the datastructure.

connected_edges

Get groups of connected edges.

connected_nodes

Get groups of connected nodes.

connectivity_matrix

Creates a connectivity matrix from a Graph datastructure.

count_crossings

Count the number of crossings (pairs of crossing edges) in the graph.

degree

Return the number of neighbors of a node.

degree_in

Return the numer of incoming neighbors of a node.

degree_matrix

Creates a degree matrix from a Graph datastructure.

degree_out

Return the number of outgoing neighbors of a node.

delete_edge

Delete an edge from the graph.

delete_node

Delete a node from the graph.

edge_attribute

Get or set an attribute of an edge.

edge_attributes

Get or set multiple attributes of an edge.

edge_coordinates

Return the coordinates of the start and end point of an edge.

edge_direction

Return the direction vector of an edge.

edge_end

Return the end point of an edge.

edge_index

Returns a dictionary that maps edge identifiers (i.e.

edge_length

Return the length of an edge.

edge_line

Return the line of an edge.

edge_midpoint

Return the location of the midpoint of an edge.

edge_point

Return the point at a parametric location along an edge.

edge_sample

Get the identifiers of a set of random edges.

edge_start

Return the start point of an edge.

edge_vector

Return the vector of an edge.

edges

Iterate over the edges of the graph.

edges_attribute

Get or set an attribute of multiple edges.

edges_attributes

Get or set multiple attributes of multiple edges.

edges_where

Get edges for which a certain condition or set of conditions is true.

edges_where_predicate

Get edges for which a certain condition or set of conditions is true using a lambda function.

embed_in_plane

Embed the graph in the plane.

exploded

Explode the graph into its connected components.

find_crossings

Identify all pairs of crossing edges in a graph.

find_cycles

Find the faces of a graph.

from_edges

Create a new graph instance from information about the edges.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

from_lines

Construct a graph from a set of lines represented by their start and end point coordinates.

from_networkx

Create a new graph instance from a NetworkX DiGraph instance.

from_nodes_and_edges

Construct a graph from nodes and edges.

from_obj

Construct a graph from the data contained in an OBJ file.

from_pointcloud

Construct a graph from random connections between the points of a pointcloud.

gkey_node

Returns a dictionary that maps geometric keys of a certain precision to the identifiers of the corresponding nodes.

has_edge

Verify if the graph contains a specific edge.

has_node

Verify if a specific node is present in the graph.

index_edge

Returns a dictionary that maps edges in a list to the corresponding vertex identifier pairs.

index_node

Returns a dictionary that maps the indices of a node list to keys in a node dictionary.

is_connected

Verify that the graph is connected.

is_crossed

Verify if a graph has crossing edges.

is_leaf

Verify if a node is a leaf.

is_node_connected

Verify if a specific node is connected.

is_planar

Check if the graph is planar.

is_planar_embedding

Verify that a graph is embedded in the plane without crossing edges.

is_xy

Verify that a graph lies in the XY plane.

join_edges

Join the edges incidental on the given node, if there are exactly two incident edges.

laplacian_matrix

Creates a Laplacian matrix from a Graph datastructure.

leaves

Return all leaves of the graph.

neighborhood

Return the nodes in the neighborhood of a node.

neighbors

Return the neighbors of a node.

neighbors_in

Return the incoming neighbors of a node.

neighbors_out

Return the outgoing neighbors of a node.

node_attribute

Get or set an attribute of a node.

node_attributes

Get or set multiple attributes of a node.

node_coordinates

Return the coordinates of a node.

node_edges

Return the edges connected to a node.

node_gkey

Returns a dictionary that maps node identifiers to the corresponding geometric key up to a certain precision.

node_index

Returns a dictionary that maps node identifiers to their corresponding index in a node list or array.

node_laplacian

Return the vector from the node to the centroid of its 1-ring neighborhood.

node_neighborhood_centroid

Return the computed centroid of the neighboring nodes.

node_point

Return the point of a node.

node_sample

Get a list of identifiers of a random set of n nodes.

nodes

Iterate over the nodes of the graph.

nodes_attribute

Get or set an attribute of multiple nodes.

nodes_attributes

Get or set multiple attributes of multiple nodes.

nodes_where

Get nodes for which a certain condition or set of conditions is true.

nodes_where_predicate

Get nodes for which a certain condition or set of conditions is true using a lambda function.

number_of_edges

Compute the number of edges of the graph.

number_of_nodes

Compute the number of nodes of the graph.

obb

Calculate the oriented bounding box of the graph.

rotate

Rotate the datastructure.

rotated

Returns a rotated copy of this geometry.

scale

Scale the datastructure.

scaled

Returns a scaled copy of this geometry.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

shortest_path

Find the shortest path between two nodes using the A* algorithm.

smooth

Smooth a graph by moving every free node to the centroid of its neighbors.

split_edge

Split and edge by inserting a node along its length.

summary

Return a summary of the graph.

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

to_lines

Return the lines of the graph as pairs of start and end point coordinates.

to_networkx

Create a new NetworkX graph instance from a graph.

to_nodes_and_edges

Return the nodes and edges of a graph.

to_obj

Write the graph to an OBJ file.

to_points

Return the coordinates of the graph.

transform

Transform all nodes of the graph.

transform_numpy

Transforms the data structure.

transformed

Returns a transformed copy of this data structure.

transformed_numpy

Returns a transformed copy of this data structure.

translate

Translate the datastructure.

translated

Returns a translated copy of this geometry.

unset_edge_attribute

Unset the attribute of an edge.

unset_node_attribute

Unset the attribute of a node.

update_default_edge_attributes

Update the default edge attributes.

update_default_node_attributes

Update the default node attributes.

validate_data

Validate the data against the object's data schema.