topologicpy.Graph module

class topologicpy.Graph.Graph

Bases: object

Methods

AABB(graph[, silent, pad])

Computes the bounding box (AABB) of the input graph.

AccessibilityCentrality(graph[, step, ...])

Computes the accessibility centrality of each vertex in the graph using random walks of fixed step length.

AddEdge(graph, edge[, ...])

Adds the input edge to the input Graph.

AddEdgeByIndex(graph[, index, dictionary, ...])

Creates an edge in the input Graph by connecting the two vertices specified by their indices (e.g., [5, 6] connects the 4th and 6th vertices).

AddVertex(graph, vertex[, tolerance, silent])

Adds the input vertex to the input graph.

AddVertexByData(graph[, dictionary, x, y, ...])

Adds a vertex to the input graph, by the input data.

AddVertices(graph, vertices[, tolerance, silent])

Adds the input list of vertices to the input graph.

AdjacencyDictionary([vertexLabelKey, ...])

Returns the adjacency dictionary of the input Graph.

AdjacencyList(graph[, vertexKey, reverse, ...])

Returns the adjacency list of the input Graph.

AdjacencyMatrix(graph[, vertexKey, reverse, ...])

Returns the adjacency matrix of the input Graph.

AdjacencyMatrixCSVString(graph[, vertexKey, ...])

Returns the adjacency matrix CSV string of the input Graph.

AdjacencyMatrixFigure(graph[, vertexKey, ...])

Returns a Plotly table figure visualizing the adjacency matrix of a Graph.

AdjacentEdges(graph, edge[, silent])

Returns the list of edges connected to the input edge.

AdjacentVertices(graph, vertex[, silent])

Returns the list of vertices connected to the input vertex.

AdjacentVerticesByCompassDirection(graph, vertex)

Returns the list of vertices connected to the input vertex that are in the input compass direction.

AdjacentVerticesByVector(graph, vertex[, ...])

Returns the list of vertices connected to the input vertex that are in the input vector direction.

AllPaths(graph, vertexA, vertexB[, ...])

Returns all the paths that connect the input vertices within the allowed time limit in seconds.

AngularBetweenness(graph[, normalize, ...])

Computes the angular betweenness of the input graph and stores the result in the dictionary of each edge.

AngularChoice(graph[, normalize, ...])

Computes the angular choice of the input graph and stores the result in the dictionary of each edge.

AngularConnectivity(graph[, key, normalize, ...])

Computes the angular connectivity of the input graph and stores the result in the dictionary of each edge.

AngularIntegration(graph[, normalize, ...])

Computes the angular integration of the input graph and stores the result in the dictionary of each edge.

AverageClusteringCoefficient(graph[, ...])

Returns the average clustering coefficient of the input graph.

BOTGraph(graph[, bidirectional, ...])

Creates an RDF graph according to the BOT ontology and the TopologicPy ontology.

BOTString(graph[, format, bidirectional, ...])

Returns an RDF graph serialized string according to the BOT ontology.

BetweennessCentrality(graph[, weightKey, ...])

Computes the betweenness centrality of the input graph and stores the result in the dictionary of each vertex or edge.

BetweennessPartition(graph[, n, m, key, ...])

Computes a partition of the input graph based on the edge betweenness method.

Bridges(graph[, key, silent])

Returns the list of bridge edges in the input graph.

ByAdjacencyMatrix(adjacencyMatrix[, ...])

Returns graphs according to the input folder path.

ByAdjacencyMatrixCSVPath(path[, ...])

Returns graphs according to the input path.

ByBOTGraph(botGraph[, includeContext, xMin, ...])

Creates a TopologicPy graph from an RDF graph encoded using the BOT ontology.

ByBOTPath(path[, includeContext, xMin, ...])

Creates a TopologicPy graph from an RDF path encoded using the BOT ontology.

ByCSVPath(path[, graphIDHeader, ...])

Imports TopologicPy graphs from a folder containing CSV files (graphs.csv, nodes.csv, edges.csv) exported using the new TopologicPy CSV format for PyTorch Geometric-style datasets.

ByCSVPath_old(path[, graphIDHeader, ...])

Returns graphs according to the input folder path.

ByDGCNNFile(file[, key, tolerance])

Creates a graph from a DGCNN File.

ByDGCNNPath(path[, key, tolerance])

Creates a graph from a DGCNN path.

ByDGCNNString(string[, key, tolerance])

Creates a graph from a DGCNN string.

ByDictionaries(graphDictionary, ...[, ...])

Creates a graph from input python dictionaries.

ByIFCFile(file[, importMode, clean, ...])

Creates a Graph from an IFC file.

ByIFCPath(path[, importMode, clean, ...])

Create a Graph from an IFC path.

ByJSONDictionary(jsonDictionary[, xKey, ...])

Loads a Graph from a JSON file and attaches graph-, vertex-, and edge-level dictionaries.

ByJSONFile(file[, xKey, yKey, zKey, ...])

Imports the graph from a JSON file.

ByJSONPath(path[, xKey, yKey, zKey, ...])

Imports the graph from a JSON file.

ByMeshData(vertices, edges[, ...])

Creates a graph from the input mesh data

ByNetworkXGraph(nxGraph[, vertexID, xKey, ...])

Converts the input NetworkX graph into a topologic Graph.

BySpatialRelationships(*topologies[, ...])

Creates a graph of the spatial relationships of the input topologies according to OGC / ISO 19107 / DE-9IM / RCC-8

ByTopology(topology[, direct, ...])

Creates a graph from the input topology.

ByTriples(triples[, subjectKey, ...])

Creates a TopologicPy Graph from RDF-style triples.

ByVerticesEdges(vertices, edges[, index, ...])

Creates a graph from the input list of vertices and edges.

CardinalityReport(graph[, vertexKey, ...])

Returns a cardinality report for vertices in a graph.

Choice(graph[, method, weightKey, ...])

This is an alias method for Graph.BetweenessCentrality. Returns the choice (Betweeness Centrality) of the input graph. The order of the returned list is the same as the order of vertices/edges. See https://en.wikipedia.org/wiki/Betweenness_centrality.

ChromaticNumber(graph[, maxColors, silent])

Returns the chromatic number of the input graph.

ClosenessCentrality(graph[, weightKey, ...])

Computes the closeness centrality of the input graph.

Color(graph[, oldKey, key, maxColors, tolerance])

Colors the input vertices within the input graph.

Community(graph[, key, colorKey, ...])

Computes the best community partition of the input graph based on the Louvain method.

CommunityPartition(graph[, key, colorKey, ...])

Computes the best community partition of the input graph using the Louvain method.

Compare(graphA, graphB[, ...])

Compares two graphs and returns a similarity score based on attributres, geometry, metrics, structure, the Weisfeiler-Lehman graph kernel.

CompiledRoutingGraph(graph[, directed, ...])

Returns a compiled routing graph object from the input graph.

Complement(graph[, ontology, tolerance, silent])

Creates the complement graph of the input graph.

Complete(graph[, ontology, tolerance, silent])

Completes the graph by conneting unconnected vertices.

Connect(graph, verticesA, verticesB[, tolerance])

Connects the two lists of input vertices.

ConnectedComponents(graph[, key, tolerance, ...])

Returns the connected components (islands) of the input graph.

Connectivity(graph[, vertices, weightKey, ...])

This is an alias method for Graph.DegreeCentrality.

ContainsEdge(graph, edge[, tolerance])

Returns True if the input graph contains the input edge.

ContainsVertex(graph, vertex[, tolerance])

Returns True if the input graph contains the input Vertex.

ContractEdge(graph, edge[, vertex, ...])

Contracts the input edge in the input graph into a single vertex.

CutVertices(graph[, key, silent])

Returns the list of cut vertices in the input graph.

DegreeCentrality(graph[, weightKey, ...])

Computes the degree centrality of the input graph.

DegreeCentrality_old(graph[, weightKey, ...])

Computes the degree centrality of the input graph.

DegreeMatrix(graph)

Returns the degree matrix of the input graph.

DegreeSequence(graph)

Returns the degree sequence of the input graph.

Density(graph)

Returns the density of the input graph.

Depth(graph[, vertex, tolerance, silent])

Computes the maximum depth of the input graph rooted at the input vertex.

DepthMap(graph[, vertices, key, type, ...])

Return the depth map of the input list of vertices within the input graph.

DetachVertex(graph, *vertices[, silent])

Detaches the input vertex from its neigboring vertices.

Diameter(graph[, silent])

Returns the diameter of the input (unweighted, undirected) graph.

Dictionary(graph)

Returns the dictionary of the input graph.

Difference(graphA, graphB, vertexKeys[, ...])

Intersect the two input graphs based on the input vertex keys.

Distance(graph, vertexA, vertexB[, type, ...])

Returns the shortest-path distance between the input vertices.

Edge(graph, vertexA, vertexB[, tolerance, ...])

Returns the edge in the input graph that connects in the input vertices.

Edges(graph[, vertices, strict, sortBy, ...])

Returns the list of edges from graph whose endpoints match the given vertices according to the strict rule.

EigenVectorCentrality(graph[, normalize, ...])

Returns the eigenvector centrality of the input graph.

ExportGraphToCSV(graph, path, graphLabel[, ...])

Exports the input graph into a set of CSV files compatible with pytorch geometric.

ExportGraphsToCSV(graphs, path[, ...])

Batch-export a list of TopologicPy graphs to CSV files (graphs.csv, nodes.csv, edges.csv) in a format suitable for graph ML pipelines.

ExportToAdjacencyMatrixCSV(adjacencyMatrix, path)

Exports the input graph into a set of CSV files compatible with pytorch geometric.

ExportToBOT(graph, path[, format, ...])

Exports the input graph to an RDF graph serialized according to the BOT ontology.

ExportToCSV(graph, path[, graphLabelKey, ...])

Exports the input graph into a set of CSV files compatible with pytorch geometric.

ExportToGEXF(graph[, path, graphWidth, ...])

Exports the input graph to a Graph Exchange XML (GEXF) file format.

ExportToGraphVizGraph(graph, path[, device, ...])

Exports the input graph to a GraphViz .gv (dot) file.

ExportToJSON(graph, path[, propertiesKey, ...])

Exports the input graph to a JSON file.

ExportToJSONLD(graph, path[, context, ...])

Exports the input graph to a JSON file.

ExportToRDF(graph, path[, subjectKey, ...])

Exports a TopologicPy Graph to an RDF/Turtle file.

ExportToWiki(graph, path[, vertexKey, ...])

Exports a TopologicPy Graph as an Obsidian-style markdown wiki.

FiedlerVector(graph[, mantissa, silent])

Computes the Fiedler vector of a graph.

FiedlerVectorPartition(graph[, key, ...])

Partitions the input graph based on FiedlerVector method.

GlobalClusteringCoefficient(graph)

Returns the global clustering coefficient of the input graph.

GraphVizGraph(graph[, device, deviceKey, ...])

Converts the input graph to a GraphViz graph.

Guid(graph)

Returns the guid of the input graph

HasseDiagram(topology[, types, topDown, ...])

Constructs a Hasse diagram from the input topology as a directed graph.

HopperKernel(graphA, graphB[, key, maxHops, ...])

Returns the Graph Hopper kernel between two graphs.

Impose(graphA, graphB[, vertexKeys, ...])

Imposes the second input graph on the first input graph based on the input vertex keys.

Imprint(graphA, graphB, vertexKeys[, ...])

Imprints the second input graph on the first input graph based on the input vertex keys.

IncomingEdges(graph, vertex[, directed, ...])

Returns the incoming edges connected to a vertex.

IncomingVertices(graph, vertex[, directed, ...])

Returns the incoming vertices connected to a vertex.

InducedSubgraph(graph[, vertices, strict, ...])

Returns the subgraph whose edges are connected to the given vertices according to the strict rule.

Integration(graph[, weightKey, normalize, ...])

This is an alias method for Graph.ClosenessCentrality.

Intersect(graphA, graphB, vertexKeys[, ...])

Intersect the two input graphs based on the input vertex keys.

IsBipartite(graph[, tolerance])

Returns True if the input graph is bipartite.

IsCompiledRoutingGraph(obj)

Returns True if the input object is a compiled routing graph.

IsComplete(graph)

Returns True if the input graph is complete.

IsConnected(graph, vertexA, vertexB[, silent])

Returns True if the two input vertices are directly connected by an edge.

IsEmpty(graph[, silent])

Tests if the input graph is empty (Has no vertices).

IsErdoesGallai(graph, sequence)

Returns True if the input sequence satisfies the Erdős–Gallai theorem.

IsIsomorphic(graphA, graphB[, ...])

Tests if the two input graphs are isomorphic according to the Weisfeiler Lehman graph isomorphism test.

IsTree(graph)

Returns True if the input graph has a hierarchical tree-like structure.

IsolatedVertices(graph)

Returns the list of isolated vertices in the input graph.

JSONData(graph[, propertiesKey, ...])

Converts the input graph into JSON data.

JSONLDData(graph[, context, verticesKey, ...])

Exports the Graph to a JSON-LD representation.

JSONLDString(graph[, context, verticesKey, ...])

Converts the input graph into a JSON-LD string.

JSONString(graph[, verticesKey, edgesKey, ...])

Converts the input graph into a JSON string.

KHopsSubgraph(graph, vertices[, k, ...])

Returns a subgraph consisting of the k-hop neighborhood around the input list of seed vertices.

Kernel(graphA, graphB[, method, key, ...])

Returns a graph-to-graph kernel value using the selected method.

Laplacian(graph[, silent, normalized])

Returns the Laplacian matrix of the input graph.

Leaves(graph[, weightKey, mantissa, ...])

Returns a list of all vertices that have a degree of 1, also called leaf nodes.

LineGraph(graph[, ...])

Returns the line graph of the input graph.

LocalClusteringCoefficient(graph[, ...])

Returns the local clustering coefficient of the input list of vertices within the input graph.

LongestPath(graph, vertexA, vertexB[, ...])

Returns the longest path that connects the input vertices.

Match(graphB[, vertexKeys, edgeKeys, ...])

Matches graphA as a subgraph of graphB using structural and semantic similarity.

MaximumDelta(graph)

Returns the maximum delta of the input graph.

MaximumFlow(graph, source, sink[, ...])

Returns the maximum flow of the input graph.

Merge(graphA, graphB[, vertexKeys, ...])

Merges the two input graphs based on the input vertex keys.

MergeVertices(graph, *vertices[, ...])

Merges the input vertices into one vertex and reconnects all edges to the new vertex.

MeshData(graph[, mantissa, tolerance])

Returns the mesh data of the input graph.

MetricDistance(graph, vertexA, vertexB[, ...])

Returns the shortest-path distance between the input vertices.

MinimumDelta(graph)

Returns the minimum delta of the input graph.

MinimumSpanningTree(graph[, edgeKey, ...])

Returns the minimum spanning tree of the input graph.

NavigationGraph(face[, sources, ...])

Creates a 2D navigation graph.

NearestVertex(graph, vertex)

Returns the vertex in the input graph that is the nearest to the input vertex.

Neigborhood(graph[, vertices, k, ...])

Returns a subgraph consisting of the k-hop neighborhood around the input list of seed vertices.

NetworkXGraph(graph[, xKey, yKey, zKey, ...])

Converts the input graph into a NetworkX Graph.

Order(graph)

Returns the graph order of the input graph.

OutgoingEdges(graph, vertex[, directed, ...])

Returns the outgoing edges connected to a vertex.

OutgoingVertices(graph, vertex[, directed, ...])

Returns the list of outgoing vertices connected to a vertex.

PageRank(graph[, alpha, maxIterations, ...])

PageRank with stable vertex mapping (by coordinates) so neighbors resolve correctly.

Partition(graph[, method, n, m, key, ...])

Partitions the input graph based on the desired partition method.

Path(graph, vertexA, vertexB[, tolerance])

Returns a path (wire) in the input graph that connects the input vertices.

PropagateValues(graph[, sourceVertexKey, ...])

Propagates dictionary values from source vertices to target vertices along selected graph edges.

PyvisGraph(graph, path[, overwrite, height, ...])

Displays a pyvis graph.

Quotient(topology[, topologyType, key, ...])

Construct the quotient graph induced by grouping sub-topologies (Cells/Faces/Edges/Vertices) by a dictionary value.

RDFString(graph[, subjectKey, predicateKey, ...])

Returns an RDF/Turtle string representation of a TopologicPy Graph.

RemoveEdge(graph, *edges[, tolerance, silent])

Removes the input edge from the input graph.

RemoveIsolatedEdges(graph[, removeVertices, ...])

Removes all isolated edges from the input graph.

RemoveIsolatedVertices(graph[, silent])

Removes all isolated vertices from the input graph.

RemoveVertex(graph, vertex[, silent])

Removes the input vertex from the input graph.

Reshape(graph[, shape, k, seed, iterations, ...])

Reshapes the input graph according to the desired input shape parameter.

SetDictionary(graph, dictionary)

Sets the input graph's dictionary to the input dictionary

ShortestPath(graph, vertexA, vertexB[, ...])

Returns the shortest path (as a Wire) between two vertices in a Graph using a pure-Python, feature-rich routing algorithm.

ShortestPathViaVertices(graph, vertexA, vertexB)

Returns a head-to-tail path from start_vertex to end_vertex that passes through, in order, vertices whose dictionary value at key matches each value in via_values.

ShortestPaths(graph, vertexA, vertexB[, ...])

Returns the shortest path that connects the input vertices.

Show(*graphs[, sagitta, absolute, sides, ...])

Shows the graph using Plotly.

Size(graph)

Returns the graph size of the input graph.

SubGraphMatches(subGraph, superGraph[, ...])

Finds all subgraph matches from subgraph into supergraph.

Subgraph(graph, vertices[, vertexKey, ...])

Returns a subgraph of the input graph as defined by the input vertices.

SymmetricDifference(graphA, graphB, vertexKeys)

Find the symmetric difference (exclusive OR / XOR) of the two input graphs based on the input vertex keys.

Tietze([radius, height])

Creates a Tietze's graph mapped on a mobius strip of the same input radius and height.

TopologicalDistance(graph, vertexA, vertexB)

Returns the topological distance between the input vertices.

Topology(graph)

Returns the topology (cluster) of the input graph

Tree(graph[, vertex, ontology, tolerance])

Creates a tree graph version of the input graph rooted at the input vertex.

Triples(graph[, subjectKey, predicateKey, ...])

Returns RDF-style triples from a TopologicPy Graph.

Union(graphA, graphB[, vertexKeys, ...])

Union the two input graphs based on the input vertex keys.

VertexByKeyValue(graph[, key, value, silent])

Returns the first vertex in the input graph whose dictionary contains the input key/value pair.

VertexDegree(graph, vertex[, weightKey, ...])

Returns the degree of the input vertex.

Vertices(graph[, sortBy, reverse, silent])

Returns the list of vertices in the input graph.

VisibilityGraph(face[, viewpointsA, ...])

Creates a 2D visibility graph.

WLFeatures(graph[, key, iterations, silent])

Returns a Weisfeiler-Lehman subtree features for a Graph.

WLKernel(graphA, graphB[, key, iterations, ...])

Returns a cosine-normalized Weisfeiler-Lehman kernel between two graphs.

WeightedJaccardSimilarity(graphA, graphB, ...)

Computes the weighted Jaccard similarity between two vertices based on their neighbors and edge weights.

WikiString(graph[, vertexKey, ...])

Returns a markdown wiki string representation of a TopologicPy Graph.

XOR(graphA, graphB, vertexKeys[, ...])

Find the symmetric difference (exclusive OR / XOR) of the two input graphs based on an input vertex key.

AccessGraph

static AABB(graph, silent: bool = False, pad: float = 0.0)

Computes the bounding box (AABB) of the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

padfloat , optional

An additional padding to add to the bounding box. Default is 0.0.

silentbool, optional

If set to True, error and warning messages are suppressed. Default is False.

static AccessGraph(topology, key: str = None, includeTypes: list = None, excludeTypes: list = None, vertexCategoryKey: str = 'category', edgeCategoryKey: str = 'category', viaSharedApertures: bool = False, toExteriorApertures: bool = False, useInternalVertex: bool = False, includeIsolatedVertices: bool = True, storeBREP: bool = False, ontology: bool = True, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)
static AccessibilityCentrality(graph, step: int = 2, normalize: bool = False, key: str = 'accessibility_centrality', colorKey: str = 'ac_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Computes the accessibility centrality of each vertex in the graph using random walks of fixed step length.

Parameters
graphtopologic_core.Graph

The input graph.

stepint, optional

The length of the random walk (number of steps). Default is 2.

normalizebool, optional

If True, normalize the output to the range 0 to 1. Default is False.

keystr, optional

Dictionary key to store the accessibility centrality value. Default is “accessibility_centrality”.

colorKeystr, optional

Dictionary key to store the color value. Default is “ac_color”.

colorScalestr, optional

Name of the Plotly color scale to use. Default is “viridis”.

mantissaint, optional

Decimal precision. Default is 6.

tolerancefloat, optional

The desired Tolerance. Not used here but included for API compatibility. Default is 0.0001.

silentbool, optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

A list of accessibility centrality values for each vertex in the graph.

static AddEdge(graph, edge, transferVertexDictionaries: bool = False, transferEdgeDictionaries: bool = False, tolerance: float = 0.0001, silent: bool = False)

Adds the input edge to the input Graph.

The added edge is assigned “src” and “dst” dictionary keys corresponding to the “index” values of its start and end vertices in the resulting graph. If a vertex does not already have an “index” key, one is assigned.

Parameters
graphtopologic_core.Graph

The input graph.

edgetopologic_core.Edge

The input edge.

transferVertexDictionariesbool, optional

If set to True, the dictionaries of the vertices are transferred to the graph.

transferEdgeDictionariesbool, optional

If set to True, the dictionaries of the edges are transferred to the graph.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with the input edge added to it.

static AddEdgeByIndex(graph, index: list = None, dictionary=None, silent: bool = False)

Creates an edge in the input Graph by connecting the two vertices specified by their indices (e.g., [5, 6] connects the 4th and 6th vertices).

Parameters
graphtopologic_core.Graph

The input graph.

indexlist or tuple

The input list of vertex indices (e.g. [4, 6]).

dictionarytopologic_core.Dictionary , optional

The input edge dictionary.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with the input edge added to it.

static AddVertex(graph, vertex, tolerance: float = 0.0001, silent: bool = False)

Adds the input vertex to the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

The input vertex.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with the input vertex added to it.

static AddVertexByData(graph, dictionary=None, x: float = None, y: float = None, z: float = None, silent: bool = False)

Adds a vertex to the input graph, by the input data.

Parameters
graphtopologic_core.Graph

The input graph.

dictionarytopologic_core.Dictionary , optional

The dictionary to be associated with this vertex. Default is None.

xfloat , optional

The x-coordinate of the vertex. If not set, it will be randomly set between 0 and 100. Default is None.

yfloat , optional

The y-coordinate of the vertex. If not set, it will be randomly set between 0 and 100. Default is None.

zfloat , optional

The z-coordinate of the vertex. If not set, it will be randomly set between 0 and 100. Default is None.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with the input vertex added to it.

static AddVertices(graph, vertices, tolerance: float = 0.0001, silent: bool = False)

Adds the input list of vertices to the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

verticeslist

The input list of vertices.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with the input vertex added to it.

AdjacencyDictionary(vertexLabelKey: str = None, edgeKey: str = 'Length', includeWeights: bool = False, mantissa: int = 6)

Returns the adjacency dictionary of the input Graph.

Parameters
graphtopologic_core.Graph

The input graph.

vertexLabelKeystr , optional

The returned vertices are labelled according to the dictionary values stored under this key. If the vertexLabelKey does not exist, it will be created and the vertices are labelled numerically and stored in the vertex dictionary under this key. Default is None.

edgeKeystr , optional

If set, the edges’ dictionaries will be searched for this key to set their weight. If the key is set to “length” (case insensitive), the length of the edge will be used as its weight. If set to None, a weight of 1 will be used. Default is “Length”.

includeWeightsbool , optional

If set to True, edge weights are included. Otherwise, they are not. Default is False.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
dict

The adjacency dictionary.

static AdjacencyList(graph, vertexKey=None, reverse=True, tolerance=0.0001)

Returns the adjacency list of the input Graph. See https://en.wikipedia.org/wiki/Adjacency_list.

Parameters
graphtopologic_core.Graph

The input graph.

vertexKeystr , optional

If set, the returned list of vertices is sorted according to the dictionary values stored under this key. Default is None.

reversebool , optional

If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The adjacency list.

static AdjacencyMatrix(graph, vertexKey=None, reverse=False, edgeKeyFwd=None, edgeKeyBwd=None, bidirKey=None, bidirectional=True, useEdgeIndex=False, useEdgeLength=False, mantissa: int = 6, tolerance=0.0001)

Returns the adjacency matrix of the input Graph. See https://en.wikipedia.org/wiki/Adjacency_matrix.

Parameters
graphtopologic_core.Graph

The input graph.

vertexKeystr , optional

If set, the returned list of vertices is sorted according to the dictionary values stored under this key. Default is None.

reversebool , optional

If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. Default is False.

edgeKeyFwdstr , optional

If set, the value at this key in the connecting edge from start vertex to end vertex (forward) will be used instead of the value 1. Default is None. useEdgeIndex and useEdgeLength override this setting.

edgeKeyBwdstr , optional

If set, the value at this key in the connecting edge from end vertex to start vertex (backward) will be used instead of the value 1. Default is None. useEdgeIndex and useEdgeLength override this setting.

bidirKeybool , optional

If set to True or False, this key in the connecting edge will be used to determine is the edge is supposed to be bidirectional or not. If set to None, the input variable bidrectional will be used instead. Default is None

bidirectionalbool , optional

If set to True, the edges in the graph that do not have a bidirKey in their dictionaries will be treated as being bidirectional. Otherwise, the start vertex and end vertex of the connecting edge will determine the direction. Default is True.

useEdgeIndexbool , optional

If set to True, the adjacency matrix values will the index of the edge in Graph.Edges(graph). Default is False. Both useEdgeIndex, useEdgeLength should not be True at the same time. If they are, useEdgeLength will be used.

useEdgeLengthbool , optional

If set to True, the adjacency matrix values will the length of the edge in Graph.Edges(graph). Default is False. Both useEdgeIndex, useEdgeLength should not be True at the same time. If they are, useEdgeLength will be used.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The adjacency matrix.

static AdjacencyMatrixCSVString(graph, vertexKey=None, reverse=False, edgeKeyFwd=None, edgeKeyBwd=None, bidirKey=None, bidirectional=True, useEdgeIndex=False, useEdgeLength=False, mantissa: int = 6, tolerance=0.0001)

Returns the adjacency matrix CSV string of the input Graph. See https://en.wikipedia.org/wiki/Adjacency_matrix.

Parameters
graphtopologic_core.Graph

The input graph.

vertexKeystr , optional

If set, the returned list of vertices is sorted according to the dictionary values stored under this key. Default is None.

reversebool , optional

If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. Default is False.

edgeKeyFwdstr , optional

If set, the value at this key in the connecting edge from start vertex to end vertex (forward) will be used instead of the value 1. Default is None. useEdgeIndex and useEdgeLength override this setting.

edgeKeyBwdstr , optional

If set, the value at this key in the connecting edge from end vertex to start vertex (backward) will be used instead of the value 1. Default is None. useEdgeIndex and useEdgeLength override this setting.

bidirKeybool , optional

If set to True or False, this key in the connecting edge will be used to determine is the edge is supposed to be bidirectional or not. If set to None, the input variable bidrectional will be used instead. Default is None

bidirectionalbool , optional

If set to True, the edges in the graph that do not have a bidireKey in their dictionaries will be treated as being bidirectional. Otherwise, the start vertex and end vertex of the connecting edge will determine the direction. Default is True.

useEdgeIndexbool , optional

If set to True, the adjacency matrix values will the index of the edge in Graph.Edges(graph). Default is False. Both useEdgeIndex, useEdgeLength should not be True at the same time. If they are, useEdgeLength will be used.

useEdgeLengthbool , optional

If set to True, the adjacency matrix values will the length of the edge in Graph.Edges(graph). Default is False. Both useEdgeIndex, useEdgeLength should not be True at the same time. If they are, useEdgeLength will be used.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
str

A string in CSV format representing the adjacency matrix. Returns an empty string if conversion fails.

static AdjacencyMatrixFigure(graph, vertexKey: str = None, showZero: bool = False, zeroChar: str = '·', zeroColor: str = 'rgba(0,0,0,0)', valueColor: str = 'rgba(0,0,0,0.05)', diagonalHighlight: bool = True, diagonalColor: str = 'rgba(0,0,0,0)', title: str = None, cellSize: int = 24, fontFamily: str = 'Arial', fontSize: int = 12, fontColor: str = 'rgba(0,0,0,0)', backgroundColor: str = 'rgba(0,0,0,0)', headerColor: str = 'rgba(0,0,0,0)', reverse=False, edgeKeyFwd=None, edgeKeyBwd=None, bidirKey=None, bidirectional=True, useEdgeIndex=False, useEdgeLength=False, mantissa: int = 6, tolerance=0.0001, silent: bool = False)

Returns a Plotly table figure visualizing the adjacency matrix of a Graph.

Parameters
graphtopologic_core.Graph

The input graph.

vertexKeystr , optional

If set, the returned list of vertices is sorted according to the dictionary values stored under this key. Default is None.

showZerobool, optional

If True, show zeros as “0”; if False, show a subtle glyph (zero_char) or blank. Default is False.

zeroCharstr, optional

Character to display for zero entries when show_zero is False. Default is “·”.

zeroColorlist or str , optional

The desired color to display for zero-valued cells. This can be any color list or plotly color string and may be specified as: - An rgb list (e.g. [255,0,0]) - A cmyk list (e.g. [0.5, 0, 0.25, 0.2]) - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is ‘rgba(0,0,0,0)’ (transparent).

valueColorlist or str , optional

The desired color to display for non-zero-valued cells. This can be any color list or plotly color string and may be specified as: - An rgb list (e.g. [255,0,0]) - A cmyk list (e.g. [0.5, 0, 0.25, 0.2]) - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is ‘rgba(0,0,0,0.35)’ (slight highlight).

diagonalHighlightbool, optional

If True, lightly highlight diagonal cells. Default is True.

diagonalColorlist or str , optional

The desired diagonal highlight color. This can be any color list or plotly color string and may be specified as: - An rgb list (e.g. [255,0,0]) - A cmyk list (e.g. [0.5, 0, 0.25, 0.2]) - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is ‘rgba(0,0,0,0)’ (transparent).

titlestr, optional

Optional figure title.

cellSizeint, optional

Approximate pixel height of each table row. Default is 24.

fontFamilystr, optional

Font family for table text. Default is “Arial”.

fontSizeint, optional

Font size for table text. Default is 12.

fontColorlist or str , optional

The desired font color. This can be any color list or plotly color string and may be specified as: - An rgb list (e.g. [255,0,0]) - A cmyk list (e.g. [0.5, 0, 0.25, 0.2]) - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is ‘rgba(0,0,0,0)’ (transparent).

backgroundColorlist or str , optional

The desired background color. This can be any color list or plotly color string and may be specified as: - An rgb list (e.g. [255,0,0]) - A cmyk list (e.g. [0.5, 0, 0.25, 0.2]) - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is ‘rgba(0,0,0,0)’ (transparent).

headerColorlist or str , optional

The desired header color. This can be any color list or plotly color string and may be specified as: - An rgb list (e.g. [255,0,0]) - A cmyk list (e.g. [0.5, 0, 0.25, 0.2]) - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is ‘rgba(0,0,0,0)’ (transparent).

reversebool , optional

If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. Default is False.

edgeKeyFwdstr , optional

If set, the value at this key in the connecting edge from start vertex to end vertex (forward) will be used instead of the value 1. Default is None. useEdgeIndex and useEdgeLength override this setting.

edgeKeyBwdstr , optional

If set, the value at this key in the connecting edge from end vertex to start vertex (backward) will be used instead of the value 1. Default is None. useEdgeIndex and useEdgeLength override this setting.

bidirKeybool , optional

If set to True or False, this key in the connecting edge will be used to determine is the edge is supposed to be bidirectional or not. If set to None, the input variable bidrectional will be used instead. Default is None

bidirectionalbool , optional

If set to True, the edges in the graph that do not have a bidireKey in their dictionaries will be treated as being bidirectional. Otherwise, the start vertex and end vertex of the connecting edge will determine the direction. Default is True.

useEdgeIndexbool , optional

If set to True, the adjacency matrix values will the index of the edge in Graph.Edges(graph). Default is False. Both useEdgeIndex, useEdgeLength should not be True at the same time. If they are, useEdgeLength will be used.

useEdgeLengthbool , optional

If set to True, the adjacency matrix values will the length of the edge in Graph.Edges(graph). Default is False. Both useEdgeIndex, useEdgeLength should not be True at the same time. If they are, useEdgeLength will be used.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool, optional

If True, suppresses warning messages. Default is False.

Returns
plotly.graph_objs._figure.Figure

A Plotly table figure containing the adjacency matrix table.

static AdjacentEdges(graph, edge, silent: bool = False)

Returns the list of edges connected to the input edge.

Parameters
graphtopologic_core.Graph

The input graph.

edgetopologic_core.Edge

the input edge.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of adjacent edges.

static AdjacentVertices(graph, vertex, silent: bool = False)

Returns the list of vertices connected to the input vertex.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

the input vertex.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of adjacent vertices.

static AdjacentVerticesByCompassDirection(graph, vertex, compassDirection: str = 'Up', tolerance: float = 0.0001, silent: bool = False)

Returns the list of vertices connected to the input vertex that are in the input compass direction.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

the input vertex.

compassDirectionstr , optional

The compass direction. See Vector.CompassDirections(). Default is “Up”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of adjacent vertices that are in the compass direction.

static AdjacentVerticesByVector(graph, vertex, vector: list = [0, 0, 1], tolerance: float = 0.0001, silent: bool = False)

Returns the list of vertices connected to the input vertex that are in the input vector direction.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

the input vertex.

vectorlist , optional

The vector direction. Default is [0,0,1].

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of adjacent vertices that are in the vector direction.

static AllPaths(graph, vertexA, vertexB, timeLimit=10, silent: bool = False)

Returns all the paths that connect the input vertices within the allowed time limit in seconds.

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex.

timeLimitint , optional

The time limit in second. Default is 10 seconds.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of all paths (wires) found within the time limit.

static AngularBetweenness(graph, normalize: bool = False, nxCompatible: bool = True, key: str = 'angular_betweenness', colorKey: str = 'angular_betweenness_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.001, silent: bool = False)

Computes the angular betweenness of the input graph and stores the result in the dictionary of each edge.

Parameters
graphtopologic_core.Graph

The input graph.

normalizebool , optional

If set to True, the values are normalized between 0 and 1. Default is False.

nxCompatiblebool , optional

If set to True, NetworkX-style normalization is applied and the normalize input is ignored. Default is True.

keystr , optional

The desired dictionary key name under which to store the calculated value. Default is “angular_betweenness”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “ab_color”.

colorScalestr , optional

The desired color scale name to use for colors. Default is “viridis”.

mantissaint , optional

The desired length of the mantissa. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of angular betweenness values in the order matching the edges of the input graph.

static AngularChoice(graph, normalize: bool = False, nxCompatible: bool = True, key: str = 'angular_choice', colorKey: str = 'angular_choice_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.001, silent: bool = False)

Computes the angular choice of the input graph and stores the result in the dictionary of each edge. See: https://www.spacesyntax.online/term/angular-choice/

Parameters
graphtopologic_core.Graph

The input graph.

normalizebool , optional

If set to True, the values are normalized between 0 and 1. Default is False.

nxCompatiblebool , optional

If set to True, NetworkX-style normalization is applied and the normalize input is ignored. Default is True.

keystr , optional

The desired dictionary key name under which to store the calculated value. Default is “angular_choice”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “angular_choice_color”.

colorScalestr , optional

The desired color scale name to use for colors. Default is “viridis”.

mantissaint , optional

The desired length of the mantissa. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of angular choice values in the order matching the edges of the input graph.

static AngularConnectivity(graph, key: str = 'angular_connectivity', normalize: bool = False, colorKey: str = 'angular_connectivity_color', colorScale: str = 'viridis', minValue: float = None, maxValue: float = None, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Computes the angular connectivity of the input graph and stores the result in the dictionary of each edge.

Parameters
graphtopologic_core.Graph

The input graph.

keystr , optional

The dictionary key under which to store the computed angular connectivity value. Default is “angular_connectivity”.

normalizebool , optional

If set to True, the computed value is normalized by the number of contributing adjacent edges. Otherwise, the raw sum is stored. Default is False.

colorKeystr , optional

The dictionary key under which to store the computed color. Default is “angular_connectivity_color”.

colorScalestr , optional

The color scale used to map values to colors. Default is “viridis”.

minValuefloat or None , optional

The minimum value used for color mapping. If set to None, the minimum value is computed from the data. Default is None.

maxValuefloat or None , optional

The maximum value used for color mapping. If set to None, the maximum value is computed from the data. Default is None.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with updated edge dictionaries.

static AngularIntegration(graph, normalize: bool = False, nxCompatible: bool = True, key: str = 'angular_integration', colorKey: str = 'angular_integration_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Computes the angular integration of the input graph and stores the result in the dictionary of each edge. See: https://www.spacesyntax.online/term/angular-integration/

Parameters
graphtopologic_core.Graph

The input graph.

normalizebool , optional

If set to True, the values are normalized between 0 and 1. Default is False.

nxCompatiblebool , optional

If set to True, the values are compatible with those derived from NetworkX. Default is True.

keystr , optional

The desired dictionary key name under which to store the calculated value. Default is “angular_integration”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “angular_integration_color”.

colorScalestr , optional

The desired colorscale name to use for colors. The default is “viridis”.

mantissaint , optional

The desired length of the mantissa (number of digits after the decimal point). Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of angular integration values in the order matching the edges of the input graph.

static AverageClusteringCoefficient(graph, mantissa: int = 6, silent: bool = False)

Returns the average clustering coefficient of the input graph. See https://en.wikipedia.org/wiki/Clustering_coefficient.

Parameters
graphtopologic_core.Graph

The input graph.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
float

The average clustering coefficient of the input graph.

static BOTGraph(graph, bidirectional: bool = False, includeAttributes: bool = False, includeLabel: bool = False, includeGeometry: bool = False, siteLabel: str = 'Site_0001', siteDictionary: dict = None, buildingLabel: str = 'Building_0001', buildingDictionary: dict = None, storeyPrefix: str = 'Storey', floorLevels: list = [], vertexLabelKey: str = 'label', typeKey: str = 'type', verticesKey: str = 'vertices', edgesKey: str = 'edges', edgeLabelKey: str = '', sourceKey: str = 'source', targetKey: str = 'target', xKey: str = 'hasX', yKey: str = 'hasY', zKey: str = 'hasZ', geometryKey: str = 'brep', spaceType: str = 'space', wallType: str = 'wall', slabType: str = 'slab', doorType: str = 'door', windowType: str = 'window', contentType: str = 'content', namespace: str = 'http://w3id.org/topologicpy#', instanceNamespace: str = 'http://w3id.org/topologicpy/instance#', mantissa: int = 6)

Creates an RDF graph according to the BOT ontology and the TopologicPy ontology.

Parameters
graphtopologic_core.Graph

The input graph.

bidirectionalbool , optional

If set to True, reverse relationships are created wherever possible. Default is False.

includeAttributesbool , optional

If set to True, vertex attributes are written out as RDF literals. Default is False.

includeLabelbool , optional

If set to True, an rdfs:label is attached to each resource. Default is False.

includeGeometrybool , optional

If set to True, geometry is written out where available. Default is False.

siteLabelstr , optional

The desired site label. Default is “Site_0001”.

siteDictionarydict , optional

The dictionary of site attributes to include in the output. Default is None.

buildingLabelstr , optional

The desired building label. Default is “Building_0001”.

buildingDictionarydict , optional

The dictionary of building attributes to include in the output. Default is None.

storeyPrefixstr , optional

The desired prefix to use for each building storey. Default is “Storey”.

floorLevelslist , optional

The list of floor levels. If not provided, floor levels are computed from slab vertices when possible.

vertexLabelKeystr , optional

The dictionary key used to retrieve vertex labels. Default is “label”.

typeKeystr , optional

The dictionary key used to retrieve vertex types. Default is “type”.

verticesKeystr , optional

The JSON key used for vertices. Default is “vertices”.

edgesKeystr , optional

The JSON key used for edges. Default is “edges”.

edgeLabelKeystr , optional

The dictionary key used to retrieve edge labels. Default is “”.

sourceKeystr , optional

The dictionary key used to store the source vertex. Default is “source”.

targetKeystr , optional

The dictionary key used to store the target vertex. Default is “target”.

xKeystr , optional

The key used for x-coordinates. Default is “hasX”.

yKeystr , optional

The key used for y-coordinates. Default is “hasY”.

zKeystr , optional

The key used for z-coordinates. Default is “hasZ”.

geometryKeystr , optional

The key used for geometry. Default is “brep”.

spaceTypestr , optional

The value used to identify spaces. Default is “space”.

wallTypestr , optional

The value used to identify walls. Default is “wall”.

slabTypestr , optional

The value used to identify slabs. Default is “slab”.

doorTypestr , optional

The value used to identify doors. Default is “door”.

windowTypestr , optional

The value used to identify windows. Default is “window”.

contentTypestr , optional

The value used to identify contents. Default is “content”.

namespacestr , optional

The TopologicPy ontology namespace. Default is “http://w3id.org/topologicpy#”.

instanceNamespacestr , optional

The instance namespace used for generated resources. Default is “http://w3id.org/topologicpy/instance#”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
rdflib.graph.Graph

The RDF graph using BOT and TopologicPy ontology terms.

static BOTString(graph, format='turtle', bidirectional: bool = False, includeAttributes: bool = False, includeLabel: bool = False, includeGeometry: bool = False, siteLabel: str = 'Site_0001', siteDictionary: dict = None, buildingLabel: str = 'Building_0001', buildingDictionary: dict = None, storeyPrefix: str = 'Storey', floorLevels: list = [], vertexLabelKey: str = 'label', typeKey: str = 'type', verticesKey: str = 'vertices', edgesKey: str = 'edges', edgeLabelKey: str = '', sourceKey: str = 'source', targetKey: str = 'target', xKey: str = 'hasX', yKey: str = 'hasY', zKey: str = 'hasZ', geometryKey: str = 'brep', spaceType: str = 'space', wallType: str = 'wall', slabType: str = 'slab', doorType: str = 'door', windowType: str = 'window', contentType: str = 'content', namespace: str = 'http://w3id.org/topologicpy#', mantissa: int = 6)

Returns an RDF graph serialized string according to the BOT ontology. See https://w3c-lbd-cg.github.io/bot/.

Parameters
graphtopologic_core.Graph

The input graph.

formatstr , optional

The desired output format, the options are listed below. Thde default is “turtle”. turtle, ttl or turtle2 : Turtle, turtle2 is just turtle with more spacing & linebreaks xml or pretty-xml : RDF/XML, Was the default format, rdflib < 6.0.0 json-ld : JSON-LD , There are further options for compact syntax and other JSON-LD variants ntriples, nt or nt11 : N-Triples , nt11 is exactly like nt, only utf8 encoded n3 : Notation-3 , N3 is a superset of Turtle that also caters for rules and a few other things trig : Trig , Turtle-like format for RDF triples + context (RDF quads) and thus multiple graphs trix : Trix , RDF/XML-like format for RDF quads nquads : N-Quads , N-Triples-like format for RDF quads

bidirectionalbool , optional

If set to True, reverse relationships are created wherever possible. Otherwise, they are not. Default is False.

includeAttributesbool , optional

If set to True, the attributes associated with vertices in the graph are written out. Otherwise, they are not. Default is False.

includeLabelbool , optional

If set to True, a label is attached to each node. Otherwise, it is not. Default is False.

includeGeometrybool , optional

If set to True, the geometry associated with vertices in the graph are written out. Otherwise, they are not. Default is False.

siteLabelstr , optional

The desired site label. Default is “Site_0001”.

siteDictionarydict , optional

The dictionary of site attributes to include in the output. Default is None.

buildingLabelstr , optional

The desired building label. Default is “Building_0001”.

buildingDictionarydict , optional

The dictionary of building attributes to include in the output. Default is None.

storeyPrefixstr , optional

The desired prefixed to use for each building storey. Default is “Storey”.

floorLevelslist , optional

The list of floor levels. This should be a numeric list, sorted from lowest to highest. If not provided, floorLevels will be computed automatically based on the vertices’ (zKey)) attribute. See below.

verticesKeystr , optional

The desired key name to call vertices. Default is “vertices”.

edgesKeystr , optional

The desired key name to call edges. Default is “edges”.

vertexLabelKeystr , optional

If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number. Note: If vertex labels are not unique, they will be forced to be unique.

edgeLabelKeystr , optional

If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number. Note: If edge labels are not unique, they will be forced to be unique.

sourceKeystr , optional

The dictionary key used to store the source vertex. Default is “source”.

targetKeystr , optional

The dictionary key used to store the target vertex. Default is “target”.

xKeystr , optional

The desired key name to use for x-coordinates. Default is “hasX”.

yKeystr , optional

The desired key name to use for y-coordinates. Default is “hasY”.

zKeystr , optional

The desired key name to use for z-coordinates. Default is “hasZ”.

geometryKeystr , optional

The desired key name to use for geometry. Default is “brep”.

typeKeystr , optional

The dictionary key to use to look up the type of the node. Default is “type”.

spaceTypestr , optional

The dictionary string value to use to look up vertices of type “space”. Default is “space”.

wallTypestr , optional

The dictionary string value to use to look up vertices of type “wall”. Default is “wall”.

slabTypestr , optional

The dictionary string value to use to look up vertices of type “slab”. Default is “slab”.

doorTypestr , optional

The dictionary string value to use to look up vertices of type “door”. Default is “door”.

windowTypestr , optional

The dictionary string value to use to look up vertices of type “window”. Default is “window”.

contentTypestr , optional

The dictionary string value to use to look up vertices of type “content”. Default is “contents”.

namespacestr , optional

The desired namespace to use in the BOT graph. Default is “http://github.com/wassimj/topologicpy/resources”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
str

The rdf graph serialized string using the BOT ontology.

static BetweennessCentrality(graph, weightKey: str = None, normalize: bool = False, nxCompatible: bool = True, useEdges: bool = False, edgeKey: str = None, angular: bool = False, angularWeightKey: str = 'angular_weight', key: str = 'betweenness_centrality', colorKey: str = 'bc_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.001, silent: bool = False)

Computes the betweenness centrality of the input graph and stores the result in the dictionary of each vertex or edge.

Parameters
graphtopologic_core.Graph

The input graph.

weightKeystr , optional

If set to None, each edge is assumed to have a weight of 1. If set to “length” or “distance”, the geometric length of each edge is used as its weight. If set to any other value, the value associated with that key in each edge’s dictionary is used as the edge weight. Default is None.

normalizebool , optional

If set to True, the values are normalized between 0 and 1. Default is False.

nxCompatiblebool , optional

If set to True, NetworkX-style normalization is applied and the normalize input is ignored. Default is True.

useEdgesbool , optional

If set to True, the calculation uses the edges rather than the vertices. Default is False.

edgeKeystr , optional

If not None, the value associated with that key in each edge’s dictionary is used to bundle the edges into one entity for the calculation. Otherwise, each edge segment is assumed to be an independent entity. Default is None.

angularbool , optional

If set to True, the calculation uses angular weights between adjacent edge segments. This option is valid only when useEdges is set to True. Default is False.

angularWeightKeystr , optional

The dictionary key under which to store the computed angular weight on the line graph edges. Default is “angular_weight”.

keystr , optional

The desired dictionary key name under which to store the calculated value. Default is “betweenness_centrality”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “bc_color”.

colorScalestr , optional

The desired color scale name to use for colors. Default is “viridis”.

mantissaint , optional

The desired length of the mantissa. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of centralities in the order matching the vertices or edges as requested.

static BetweennessPartition(graph, n=2, m=10, key='partition', tolerance=0.0001, silent=False)

Computes a partition of the input graph based on the edge betweenness method. See https://en.wikipedia.org/wiki/Graph_partition.

Parameters
graphtopologicp.Graph

The input topologic graph.

nint , optional

The desired number of partitions when selecting the “Betweenness” method. This parameter is ignored for other methods. Default is 2.

mint , optional

The desired maximum number of tries to partition the graph when selecting the “Betweenness” method. This parameter is ignored for other methods. Default is 10.

keystr , optional

The vertex and edge dictionary key under which to store the parition number. Default is “partition”. Valid partition numbers start from 1. Cut edges receive a partition number of 0.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologicpy.Graph

The partitioned topologic graph.

static Bridges(graph, key: str = 'bridge', silent: bool = False)

Returns the list of bridge edges in the input graph. See: https://en.wikipedia.org/wiki/Bridge_(graph_theory)

Parameters
graphtopologic_core.Graph

The input graph.

keystr , optional

The edge dictionary key under which to store the bridge status. 0 means the edge is NOT a bridge. 1 means that the edge IS a bridge. Default is “bridge”.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of bridge edges in the input graph.

static ByAdjacencyMatrix(adjacencyMatrix, dictionaries=None, edgeKeyFwd='weightFwd', edgeKeyBwd='weightBwd', xMin=-0.5, yMin=-0.5, zMin=-0.5, xMax=0.5, yMax=0.5, zMax=0.5, ontology: bool = True, silent=False)

Returns graphs according to the input folder path. This method assumes the CSV files follow pytorch geometric schema.

Parameters
adjacencyMatrixlist

The adjacency matrix expressed as a nested list of 0s and a number not 0 which represents the edge weight.

dictionarieslist , optional

A list of dictionaries to assign to the vertices of the graph. This list should be in the same order and of the same length as the rows in the adjacency matrix.

edgeKeyFwdstr , optional

The dictionary key under which to store the edge weight value for forward edge. Default is “weight”.

edgeKeyBwdstr , optional

The dictionary key under which to store the edge weight value for backward edge. Default is “weight”.

xMinfloat , optional

The desired minimum value to assign for a vertex’s X coordinate. Default is -0.5.

yMinfloat , optional

The desired minimum value to assign for a vertex’s Y coordinate. Default is -0.5.

zMinfloat , optional

The desired minimum value to assign for a vertex’s Z coordinate. Default is -0.5.

xMaxfloat , optional

The desired maximum value to assign for a vertex’s X coordinate. Default is 0.5.

yMaxfloat , optional

The desired maximum value to assign for a vertex’s Y coordinate. Default is 0.5.

zMaxfloat , optional

The desired maximum value to assign for a vertex’s Z coordinate. Default is 0.5.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

silentbool , optional

If set to True, no warnings or error messages are displayed. Default is False.

Returns
topologic_core.Graph

The created graph.

static ByAdjacencyMatrixCSVPath(path: str, dictionaries: list = None, ontology: bool = True, silent: bool = False)

Returns graphs according to the input path. This method assumes the CSV files follow an adjacency matrix schema.

Parameters
pathstr

The file path to the adjacency matrix CSV file.

dictionarieslist , optional

A list of dictionaries to assign to the vertices of the graph. This list should be in the same order and of the same length as the rows in the adjacency matrix.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

silentbool , optional

If set to True, no warnings or error messages are displayed. Default is False.

Returns
topologic_core.Graph

The created graph.

static ByBOTGraph(botGraph, includeContext: bool = False, xMin: float = -0.5, xMax: float = 0.5, yMin: float = -0.5, yMax: float = 0.5, zMin: float = -0.5, zMax: float = 0.5, ontology: bool = True, tolerance: float = 0.0001, silent: bool = False)

Creates a TopologicPy graph from an RDF graph encoded using the BOT ontology.

Parameters
botGraphrdflib.graph.Graph

The input RDF graph.

includeContextbool , optional

If set to True, Site, Building, and Storey nodes and relations are included. Default is False.

xMinfloat , optional

The minimum fallback X coordinate. Default is -0.5.

xMaxfloat , optional

The maximum fallback X coordinate. Default is 0.5.

yMinfloat , optional

The minimum fallback Y coordinate. Default is -0.5.

yMaxfloat , optional

The maximum fallback Y coordinate. Default is 0.5.

zMinfloat , optional

The minimum fallback Z coordinate. Default is -0.5.

zMaxfloat , optional

The maximum fallback Z coordinate. Default is 0.5.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created graph. Default is True.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The created TopologicPy graph.

static ByBOTPath(path, includeContext: bool = False, xMin: float = -0.5, xMax: float = 0.5, yMin: float = -0.5, yMax: float = 0.5, zMin: float = -0.5, zMax: float = 0.5, ontology: bool = True, tolerance: float = 0.0001, silent: bool = False)

Creates a TopologicPy graph from an RDF path encoded using the BOT ontology.

Parameters
pathstr

The file path to the input RDF graph.

includeContextbool , optional

If set to True, Site, Building, and Storey nodes and relations are included. Default is False.

xMinfloat , optional

The minimum fallback X coordinate. Default is -0.5.

xMaxfloat , optional

The maximum fallback X coordinate. Default is 0.5.

yMinfloat , optional

The minimum fallback Y coordinate. Default is -0.5.

yMaxfloat , optional

The maximum fallback Y coordinate. Default is 0.5.

zMinfloat , optional

The minimum fallback Z coordinate. Default is -0.5.

zMaxfloat , optional

The maximum fallback Z coordinate. Default is 0.5.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The created TopologicPy graph.

static ByCSVPath(path, graphIDHeader='graph_id', graphLabelHeader='label', graphFeaturesHeader='feat', graphFeaturesKeys=None, edgeSRCHeader='src_id', edgeDSTHeader='dst_id', edgeLabelHeader='label', edgeTrainMaskHeader='train_mask', edgeValidateMaskHeader='val_mask', edgeTestMaskHeader='test_mask', edgeFeaturesHeader='feat', edgeFeaturesKeys=None, nodeIDHeader='node_id', nodeLabelHeader='label', nodeTrainMaskHeader='train_mask', nodeValidateMaskHeader='val_mask', nodeTestMaskHeader='test_mask', nodeFeaturesHeader='feat', nodeXHeader='X', nodeYHeader='Y', nodeZHeader='Z', nodeFeaturesKeys=None, ontology: bool = True, tolerance=0.0001, silent=False)

Imports TopologicPy graphs from a folder containing CSV files (graphs.csv, nodes.csv, edges.csv) exported using the new TopologicPy CSV format for PyTorch Geometric-style datasets.

New format changes handled - Graph, node, and edge features are stored in separate numeric columns:

<featuresHeader>_0, <featuresHeader>_1, <featuresHeader>_2, …

(instead of a single comma-separated string column). - Graph label and graph features are embedded in the returned graph’s dictionary.

Parameters
pathstr

The path to the folder containing graphs.csv, nodes.csv, edges.csv.

graphIDHeaderstr , optional

The graph id column header. Default is “graph_id”.

graphLabelHeaderstr , optional

The graph label column header. Default is “label”.

graphFeaturesHeaderstr , optional

The graph features prefix. Feature columns start with “<graphFeaturesHeader>_”. Default is “feat”.

graphFeaturesKeyslist , optional

If provided, these keys are used to store graph features in the graph dictionary. Length must match number of graph feature columns found. If None, keys will be “<graphFeaturesHeader>_0”, “<graphFeaturesHeader>_1”, …

edgeSRCHeaderstr , optional

Edge source node id header. Default is “src_id”.

edgeDSTHeaderstr , optional

Edge destination node id header. Default is “dst_id”.

edgeLabelHeaderstr , optional

Edge label header. Default is “label”.

edgeTrainMaskHeader, edgeValidateMaskHeader, edgeTestMaskHeaderstr , optional

Edge mask headers. Defaults are “train_mask”, “val_mask”, “test_mask”.

edgeFeaturesHeaderstr , optional

Edge features prefix. Feature columns start with “<edgeFeaturesHeader>_”. Default is “feat”.

edgeFeaturesKeyslist , optional

If provided, these keys are used to store edge features in the edge dictionary. Length must match number of edge feature columns found. If None, keys will be “<edgeFeaturesHeader>_0”, “<edgeFeaturesHeader>_1”, …

nodeIDHeaderstr , optional

Node id header. Default is “node_id”.

nodeLabelHeaderstr , optional

Node label header. Default is “label”.

nodeTrainMaskHeader, nodeValidateMaskHeader, nodeTestMaskHeaderstr , optional

Node mask headers. Defaults are “train_mask”, “val_mask”, “test_mask”.

nodeFeaturesHeaderstr , optional

Node features prefix. Feature columns start with “<nodeFeaturesHeader>_”. Default is “feat”.

nodeXHeader, nodeYHeader, nodeZHeaderstr , optional

Node coordinate headers. Defaults are “X”, “Y”, “Z”. If missing, coordinates will be generated deterministically from node_id.

nodeFeaturesKeyslist , optional

If provided, these keys are used to store node features in the node dictionary. Length must match number of node feature columns found. If None, keys will be “<nodeFeaturesHeader>_0”, “<nodeFeaturesHeader>_1”, …

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

Desired tolerance. Default is 0.0001.

silentbool , optional

If True, warnings/errors are suppressed. Default is False.

Returns
list

A list of imported TopologicPy graphs.

static ByCSVPath_old(path, graphIDHeader='graph_id', graphLabelHeader='label', graphFeaturesHeader='feat', graphFeaturesKeys=[], edgeSRCHeader='src_id', edgeDSTHeader='dst_id', edgeLabelHeader='label', edgeTrainMaskHeader='train_mask', edgeValidateMaskHeader='val_mask', edgeTestMaskHeader='test_mask', edgeFeaturesHeader='feat', edgeFeaturesKeys=[], nodeIDHeader='node_id', nodeLabelHeader='label', nodeTrainMaskHeader='train_mask', nodeValidateMaskHeader='val_mask', nodeTestMaskHeader='test_mask', nodeFeaturesHeader='feat', nodeXHeader='X', nodeYHeader='Y', nodeZHeader='Z', nodeFeaturesKeys=[], tolerance=0.0001, silent=False)

Returns graphs according to the input folder path. This method assumes the CSV files follow pytorch geometric schema.

Parameters
pathstr

The path to the folder containing the .yaml and .csv files for graphs, edges, and nodes.

graphIDHeaderstr , optional

The column header string used to specify the graph id. Default is “graph_id”.

graphLabelHeaderstr , optional

The column header string used to specify the graph label. Default is “label”.

graphFeaturesHeaderstr , optional

The column header string used to specify the graph features. Default is “feat”.

edgeSRCHeaderstr , optional

The column header string used to specify the source vertex id of edges. Default is “src_id”.

edgeDSTHeaderstr , optional

The column header string used to specify the destination vertex id of edges. Default is “dst_id”.

edgeLabelHeaderstr , optional

The column header string used to specify the label of edges. Default is “label”.

edgeTrainMaskHeaderstr , optional

The column header string used to specify the train mask of edges. Default is “train_mask”.

edgeValidateMaskHeaderstr , optional

The column header string used to specify the validate mask of edges. Default is “val_mask”.

edgeTestMaskHeaderstr , optional

The column header string used to specify the test mask of edges. Default is “test_mask”.

edgeFeaturesHeaderstr , optional

The column header string used to specify the features of edges. Default is “feat”.

edgeFeaturesKeyslist , optional

The list of dictionary keys to use to index the edge features. The length of this list must match the length of edge features. Default is [].

nodeIDHeaderstr , optional

The column header string used to specify the id of nodes. Default is “node_id”.

nodeLabelHeaderstr , optional

The column header string used to specify the label of nodes. Default is “label”.

nodeTrainMaskHeaderstr , optional

The column header string used to specify the train mask of nodes. Default is “train_mask”.

nodeValidateMaskHeaderstr , optional

The column header string used to specify the validate mask of nodes. Default is “val_mask”.

nodeTestMaskHeaderstr , optional

The column header string used to specify the test mask of nodes. Default is “test_mask”.

nodeFeaturesHeaderstr , optional

The column header string used to specify the features of nodes. Default is “feat”.

nodeXHeaderstr , optional

The column header string used to specify the X coordinate of nodes. Default is “X”.

nodeYHeaderstr , optional

The column header string used to specify the Y coordinate of nodes. Default is “Y”.

nodeZHeaderstr , optional

The column header string used to specify the Z coordinate of nodes. Default is “Z”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
dict

The dictionary of pytorch geometric graphs and labels found in the input CSV files. The keys in the dictionary are “graphs”, “labels”, “features”

static ByDGCNNFile(file, key: str = 'label', tolerance: float = 0.0001)

Creates a graph from a DGCNN File.

Parameters
filefile object

The input file.

keystr , optional

The desired key for storing the node label. Default is “label”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
dict

A dictionary with the graphs and labels. The keys are ‘graphs’ and ‘labels’.

static ByDGCNNPath(path, key: str = 'label', tolerance: float = 0.0001)

Creates a graph from a DGCNN path.

Parameters
pathstr

The input file path.

keystr , optional

The desired key for storing the node label. Default is “label”.

tolerancestr , optional

The desired tolerance. Default is 0.0001.

Returns
dict

A dictionary with the graphs and labels. The keys are ‘graphs’ and ‘labels’.

static ByDGCNNString(string, key: str = 'label', tolerance: float = 0.0001)

Creates a graph from a DGCNN string.

Parameters
stringstr

The input string.

keystr , optional

The desired key for storing the node label. Default is “label”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
dict

A dictionary with the graphs and labels. The keys are ‘graphs’ and ‘labels’.

static ByDictionaries(graphDictionary, vertexDictionaries, edgeDictionaries, vertexKey: str = None, edgeKey: str = None, silent: bool = False, tolerance: float = 0.0001)

Creates a graph from input python dictionaries.

Rules: All vertex dictionaries must contain at least the vertexKey. All edge dictionaries must contain at least the edgeKey. The edgeKey must be a tuple or list of two str values. x,y,z coordinates are optional. However, if a vertex dictionary contains x,y,z coordinates then all vertex dictionaries must contain x,y,z coordinates. If vertex dictionaries contain x,y,z coordinates they must not overlap and be separated by a distance greater than tolerance. Keys and values are case sensitive. x,y,z keys, if present must be lowercase.

Example: graphDictionary = {“name”: “Small Apartment”, “location”: “123 Main Street”} vertexDictionaries = [

{“name”:”Entry”, “type”:”Circulation”, “x”:1, “y”:4, “z”:0, “area”:5}, {“name”:”Living Room”, “type”:”Living Room”, “x”:3, “y”:4 , “z”:0, “area”:24}, {“name”:”Dining Room”, “type”:”Dining Room”, “x”:5, “y”:2, “z”:0, “area”:18}, {“name”:”Kitchen”, “type”:”Kitchen”, “x”:1, “y”:2, “z”:0, “area”:15}, {“name”:”Bathroom”, “type”:”Bathroom”, “x”:3, “y”:6, “z”:0, “area”:9}, {“name”:”Bedroom”, “type”:”Bedroom”, “x”:5, “y”:4, “z”:0, “area”:16}

] edgeDictionaries = [

{“connects”: (“Entry”,”Living Room”), “relationship”: “adjacent_to”}, {“connects”: (“Living Room”,”Kitchen”), “relationship”: “adjacent_to”}, {“connects”: (“Dining Room”,”Kitchen”), “relationship”: “adjacent_to”}, {“connects”: (“Living Room”,”Dining Room”), “relationship”: “adjacent_to”}, {“connects”: (“Living Room”,”Bedroom”), “relationship”: “adjacent_to”}, {“connects”: (“Living Room”,”Bathroom”), “relationship”: “adjacent_to”}

] vertexKey = “name” edgeKey = “connects”

Parameters
graphDictionarydict

The python dictionary to associate with the resulting graph

vertexDictionarieslist

The input list of vertex dictionaries. These must contain the vertexKey. X,Y,Z coordinates are optional.

edgeDictionarieslist

The input list of edge dictionaries. These must have the edgeKey to specify the two vertices they connect (by using the vertexKey)

vertexKey: str

The vertex key used to identify which vertices and edge connects.

edgeKey: str

The edge key under which the pair of vertex keys are listed as a tuple or list.

tolerance: float , optional

The desired tolerance. The default is 0.0001

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The resulting graph

static ByIFCFile(file, importMode: str = 'topology', clean: bool = False, storeBREP: bool = False, useInternalVertex: bool = False, includeTypes: list = None, excludeTypes: list = None, includeRels: list = None, excludeRels: list = None, dictionaryMode: str = 'basic', xMin: float = -0.5, yMin: float = -0.5, zMin: float = -0.5, xMax: float = 0.5, yMax: float = 0.5, zMax: float = 0.5, vertexColorKey='color', edgeColorKey='color', colorScale='viridis', epsilon: float = 0.01, angTolerance: float = 0.1, tolerance: float = 0.0001, silent: bool = False)

Creates a Graph from an IFC file.

Supported relationship extraction is convention-based and includes IFC relationships with Relating* and Related* attributes, including but not limited to:

  • IfcRelConnectsPorts

  • IfcRelConnectsPortToElement

  • IfcRelAggregates

  • IfcRelNests

  • IfcRelAssignsToGroup

  • IfcRelConnectsPathElements

  • IfcRelConnectsStructuralMember

  • IfcRelContainedInSpatialStructure

  • IfcRelFillsElement

  • IfcRelSpaceBoundary

  • IfcRelVoidsElement

  • IfcRelDefinesByProperties

  • IfcRelAssociatesMaterial

  • IfcRelDefinesByType

Parameters
fileifcopenshell.file or str

The input IFC file object or path to an IFC file.

importModestr , optional

Import mode. Options are: - “topology”: build representative vertices directly from IFC entities. - “geometry”: build representative vertices from imported Topologic geometry. - “triples”: build the graph from IFC RDF-like triplets extracted from IFC relationships. - “semantic”: alias for “triples” reserved for future semantic enrichment workflows. Default is “topology”.

cleanbool , optional

If set to True, coplanar faces and collinear edges are removed. Default is False.

storeBREPbool , optional

In geometry mode, if set to True, stores the BREP of the element in its representative vertex dictionary under the key “BREP”. Default is False.

useInternalVertexbool , optional

In geometry mode, if set to True, uses an internal vertex to represent the subtopology. Otherwise, uses its centroid. Default is False.

includeTypeslist , optional

A list of IFC entity types to include as primary graph vertices. Default is None, which means all supported object types are included.

excludeTypeslist , optional

A list of IFC entity types to exclude from the graph. Default is None.

includeRelslist , optional

A list of IFC relationship types to include. Default is None, which means all relationship types are included.

excludeRelslist , optional

A list of IFC relationship types to exclude. Default is None.

dictionaryModestr , optional

Options are “none”, “basic”, or “psets”. Default is “basic”.

xMinfloat , optional

Desired minimum X coordinate for topology layout. Default is -0.5.

yMinfloat , optional

Desired minimum Y coordinate for topology layout. Default is -0.5.

zMinfloat , optional

Desired minimum Z coordinate for topology layout. Default is -0.5.

xMaxfloat , optional

Desired maximum X coordinate for topology layout. Default is 0.5.

yMaxfloat , optional

Desired maximum Y coordinate for topology layout. Default is 0.5.

zMaxfloat , optional

Desired maximum Z coordinate for topology layout. Default is 0.5.

vertexColorKeystr , optional

The desired vertex dictionary key name under which to store the calculated color. Default is “color”.

edgeColorKeystr , optional

The desired edge dictionary key name under which to store the calculated color. Default is “color”.

colorScalestr , optional

The desired colorscale name to use for colors. The default is “viridis”.

epsilonfloat , optional

Desired tolerance for removing coplanar faces. Default is 0.01.

angTolerancefloat , optional

Angular tolerance removing collinear edges. Default is 0.1.

tolerancefloat , optional

Desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The created graph.

Notes

This implementation avoids reparsing the IFC file for colour assignment. Element and relationship colour palettes are derived from dictionaries already created during graph construction.

static ByIFCPath(path, importMode: str = 'topology', clean: bool = False, storeBREP: bool = False, useInternalVertex: bool = False, dictionaryMode: str = 'basic', includeTypes: list = None, excludeTypes: list = None, includeRels: list = None, excludeRels: list = None, xMin: float = -0.5, yMin: float = -0.5, zMin: float = -0.5, xMax: float = 0.5, yMax: float = 0.5, zMax: float = 0.5, vertexColorKey: str = 'color', edgeColorKey: str = 'color', colorScale: str = 'viridis', epsilon: float = 0.01, angTolerance: float = 0.1, tolerance: float = 0.0001, silent: bool = False)

Create a Graph from an IFC path. This code is partially based on code from Bruno Postle. Supported relationship types are: “IfcRelConnectsPorts” “IfcRelConnectsPortToElement” “IfcRelAggregates” “IfcRelNests” “IfcRelAssignsToGroup “IfcRelConnectsPathElements” “IfcRelConnectsStructuralMember” “IfcRelContainedInSpatialStructure” “IfcRelFillsElement” “IfcRelSpaceBoundary” “IfcRelVoidsElement” “IfcRelDefinesByProperties” “IfcRelAssociatesMaterial” “IfcRelDefinesByType”

Parameters
pathstr

The input IFC file path.

importModestr , optional

Import mode. Options are: - “topology”: build representative vertices directly from IFC entities and - “geometry”: build representative vertices from full imported geometry Default is “topology”.

cleanbool , optional

In geometry mode, if set to True, coplanar faces and collinear edges are removed. Default is False.

storeBREPbool , optional

In geometry mode, if set to True, store the BREP of the element. in its representative vertex. The dictionary key is “BREP”. Default is False.

useInternalVertexbool , optional

In geometry mode, if set to True, use an internal vertex to represent the subtopology. Otherwise, use its centroid. Default is False.

dictionaryModestr , optional

What dictionaries to import from the IFC file. Options are “none”, “basic”, or “all”. Default is “basic”.

includeTypeslist , optional

A list of IFC object types to include in the graph. Default is None which means all object types are included.

excludeTypeslist , optional

A list of IFC object types to exclude from the graph. Default is None which means no object type is excluded.

includeRelslist , optional

A list of IFC relationship types to include in the graph. Default is None which means all relationship types are included.

excludeRelslist , optional

A list of IFC relationship types to exclude from the graph. Default is None which means no relationship type is excluded.

xMinfloat , optional

Desired minimum X coordinate for topology layout. Default is -0.5.

yMinfloat , optional

Desired minimum Y coordinate for topology layout. Default is -0.5.

zMinfloat , optional

Desired minimum Z coordinate for topology layout. Default is -0.5.

xMaxfloat , optional

Desired maximum X coordinate for topology layout. Default is 0.5.

yMaxfloat , optional

Desired maximum Y coordinate for topology layout. Default is 0.5.

zMaxfloat , optional

Desired maximum Z coordinate for topology layout. Default is 0.5.

vertexColorKeystr , optional

The desired vertex dictionary key name under which to store the calculated color. Default is “color”

edgeColorKeystr , optional

The desired edge dictionary key name under which to store the calculated color. Default is “color”

colorScalestr , optional

The desired colorscale name to use for colors. The default is “viridis”.

epsilonfloat , optional

The desired tolerance for removing coplanar faces. Default is 0.01.

angTolerancefloat , optional

The desired angular tolerance for removing collinear edges. Default is 0.1.

tolerancefloat , optional

Desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The created graph.

static ByJSONDictionary(jsonDictionary: dict, xKey: str = 'x', yKey: str = 'y', zKey: str = 'z', vertexIDKey: str = None, edgeSourceKey: str = 'source', edgeTargetKey: str = 'target', edgeIDKey: str = None, graphPropsKey: str = 'properties', verticesKey: str = 'vertices', edgesKey: str = 'edges', ontology: bool = True, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Loads a Graph from a JSON file and attaches graph-, vertex-, and edge-level dictionaries.

Parameters
pathstr

Path to a JSON file containing: - graph-level properties under graphPropsKey (default “properties”), - a vertex dict under verticesKey (default “vertices”) keyed by vertex IDs, - an edge dict under edgesKey (default “edges”) keyed by edge IDs.

xKey: str , optional

JSON key used to read vertex’s x coordinate. Default is “x”.

yKey: str , optional

JSON key used to read vertex’s y coordinate. Default is “y”.

zKey: str , optional

JSON key used to read vertex’s z coordinate. Default is “z”.

vertexIDKeystr , optional

If not None, the vertex dictionary key under which to store the JSON vertex id. Default is “id”.

edgeSourceKey: str , optional

JSON key used to read edge’s start vertex. Default is “source”.

edgeTargetKey: str , optional

JSON key used to read edge’s end vertex. Default is “target”.

edgeIDKeystr , optional

If not None, the edge dictionary key under which to store the JSON edge id. Default is “id”.

graphPropsKey: str , optional

JSON key for the graph properties section. Default is “properties”.

verticesKey: str , optional

JSON key for the vertices section. Default is “vertices”.

edgesKey: str , optional

JSON key for the edges section. Default is “edges”.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

mantissaint , optional

The desired length of the mantissa. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, no warnings or error messages are displayed. Default is False.

Returns
topologic_core.Graph
static ByJSONFile(file, xKey: str = 'x', yKey: str = 'y', zKey: str = 'z', vertexIDKey: str = 'id', edgeSourceKey: str = 'source', edgeTargetKey: str = 'target', edgeIDKey: str = 'id', graphPropsKey: str = 'properties', verticesKey: str = 'vertices', edgesKey: str = 'edges', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Imports the graph from a JSON file.

Parameters
filefile object

The input JSON file.

xKey: str , optional

JSON key used to read vertex’s x coordinate. Default is “x”.

yKey: str , optional

JSON key used to read vertex’s y coordinate. Default is “y”.

zKey: str , optional

JSON key used to read vertex’s z coordinate. Default is “z”.

vertexIDKeystr , optional

If not None, the vertex dictionary key under which to store the JSON vertex id. Default is “id”.

edgeSourceKey: str , optional

JSON key used to read edge’s start vertex. Default is “source”.

edgeTargetKey: str , optional

JSON key used to read edge’s end vertex. Default is “target”.

edgeIDKeystr , optional

If not None, the edge dictionary key under which to store the JSON edge id. Default is “id”.

graphPropsKey: str , optional

JSON key for the graph properties section. Default is “properties”.

verticesKey: str , optional

JSON key for the vertices section. Default is “vertices”.

edgesKey: str , optional

JSON key for the edges section. Default is “edges”.

mantissaint , optional

The desired length of the mantissa. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, no warnings or error messages are displayed. Default is False.

Returns
topologic_graph

the imported graph.

static ByJSONPath(path, xKey: str = 'x', yKey: str = 'y', zKey: str = 'z', vertexIDKey: str = 'id', edgeSourceKey: str = 'source', edgeTargetKey: str = 'target', edgeIDKey: str = 'id', graphPropsKey: str = 'properties', verticesKey: str = 'vertices', edgesKey: str = 'edges', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Imports the graph from a JSON file.

Parameters
pathstr

The file path to the json file.

xKey: str , optional

JSON key used to read vertex’s x coordinate. Default is “x”.

yKey: str , optional

JSON key used to read vertex’s y coordinate. Default is “y”.

zKey: str , optional

JSON key used to read vertex’s z coordinate. Default is “z”.

vertexIDKeystr , optional

If not None, the vertex dictionary key under which to store the JSON vertex id. Default is “id”.

edgeSourceKey: str , optional

JSON key used to read edge’s start vertex. Default is “source”.

edgeTargetKey: str , optional

JSON key used to read edge’s end vertex. Default is “target”.

edgeIDKeystr , optional

If not None, the edge dictionary key under which to store the JSON edge id. Default is “id”.

graphPropsKey: str , optional

JSON key for the graph properties section. Default is “properties”.

verticesKey: str , optional

JSON key for the vertices section. Default is “vertices”.

edgesKey: str , optional

JSON key for the edges section. Default is “edges”.

mantissaint , optional

The desired length of the mantissa. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, no warnings or error messages are displayed. Default is False.

Returns
list

The list of imported topologies.

static ByMeshData(vertices, edges, vertexDictionaries=None, edgeDictionaries=None, ontology: bool = True, tolerance: float = 0.0001)

Creates a graph from the input mesh data

Parameters
verticeslist

The list of [x, y, z] coordinates of the vertices/

edgeslist

the list of [i, j] indices into the vertices list to signify and edge that connects vertices[i] to vertices[j].

vertexDictionarieslist , optional

The python dictionaries of the vertices (in the same order as the list of vertices).

edgeDictionarieslist , optional

The python dictionaries of the edges (in the same order as the list of edges).

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Graph

The created graph

static ByNetworkXGraph(nxGraph, vertexID='id', xKey='x', yKey='y', zKey='z', coordsKey='coords', randomRange=(-1, 1), mantissa: int = 6, tolerance: float = 0.0001)

Converts the input NetworkX graph into a topologic Graph. See http://networkx.org

Parameters
nxGraphNetworkX graph

The input NetworkX graph.

vertexIDstr , optional

The dictionary key under which the node id should be stored. The default is “id”.

xKeystr , optional

The dictionary key under which to find the X-Coordinate of the vertex. Default is ‘x’.

yKeystr , optional

The dictionary key under which to find the Y-Coordinate of the vertex. Default is ‘y’.

zKeystr , optional

The dictionary key under which to find the Z-Coordinate of the vertex. Default is ‘z’.

coordsKeystr , optional

The dictionary key under which to find the list of the coordinates vertex. Default is ‘coords’.

randomRangetuple , optional

The range to use for random position coordinates if no values are found in the dictionaries. Default is (-1,1)

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologicpy.Graph

The created topologic graph.

static BySpatialRelationships(*topologies, include: list = ['contains', 'coveredBy', 'covers', 'crosses', 'disjoint', 'equals', 'overlaps', 'touches', 'within', 'proximity'], proximityValues=[1, 5, 10], proximityLabels=['near', 'intermediate', 'far'], useShortestDistance: bool = False, useInternalVertex: bool = False, vertexIDKey: str = 'id', edgeKeyFwd: str = 'relFwd', edgeKeyBwd: str = 'relBwd', connectsKey: str = 'connects', storeBREP: bool = False, edgeColorKey: str = 'color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Creates a graph of the spatial relationships of the input topologies according to OGC / ISO 19107 / DE-9IM / RCC-8

Parameters
*topologieslist

The list of input topologies

includelist , optional

The type(s) of spatial relationships to build. Default is [“contains”, “disjoint”, “equals”, “overlaps”, “touches”, “within”, “covers”, “coveredBy”]

proximityValues: list , optional

The list of maximum distance values that specify the desired proximityLabel. This list must be sorted in ascending order and have the same number of elements as the proximityLabels list. Objects that are further than the largest specified distance are not classified and not included. An object is considered to fall within the range if it is less than or equal to the value in this list. If you wish ALL objects to be classified specifiy the last number in this list to be larger than the largest distance that can exist between any two objects in the list. Default is [1, 5, 10]

proximityLabels: list , optional

The list of range labels (e.g. “near”, “intermediate”, “far”) that correspond to the proximityValues list. The list must have the same number of elements as the proximityValues list. Default is [“near”, “intermediate”, “far”]

useShortestDistance: bool , optional

If set to True, the shortest distance between objects is used. Otherwise, the distance between their centroids is used. Default is False.

useInternalVertex: bool , optional

If set to True, an internal vertex of the represented topology will be used as a graph node. Otherwise, its centroid will be used. Default is False.

vertexIDKey: str, optional

The vertex ID key under which to store a unique numerical and sequential id. Default is “id”.

edgeKeyFwd: str , optional

The edge key under which to store the forward relationship (from start vertex to end vertex). Default is “relFwd”.

edgeKeyBwd: str , optional

The edge key under which to store the backward relationship (from end vertex to start vertex). Default is “relBwd”.

connectsKey: str , optional

The edge key under which to store the indices of the vertices connected by each edge. Default is “connects”.

storeBREPbool , optional

If set to True, store the BRep of the topology in its representative vertex. Default is False.

mantissaint , optional

The desired length of the mantissa. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.graph

The created graph.

static ByTopology(topology, direct: bool = True, directApertures: bool = False, viaSharedTopologies: bool = False, viaSharedApertures: bool = False, toExteriorTopologies: bool = False, toExteriorApertures: bool = False, toContents: bool = False, toOutposts: bool = False, idKey: str = 'TOPOLOGIC_ID', outpostsKey: str = 'outposts', vertexCategoryKey: str = 'category', edgeCategoryKey: str = 'category', useInternalVertex: bool = False, storeBREP: bool = False, ontology: bool = True, mantissa: int = 6, tolerance: float = 0.0001, silent: float = False)

Creates a graph from the input topology.

This version assigns stable graph-local integer “index” keys to graph vertices and stable graph-local “src” and “dst” keys to graph edges. Existing index, src, and dst values copied from source topology dictionaries are ignored for graph construction. Self-loops are prevented before geometric edge creation.

Parameters
topologytopologic_core.Topology

The input topology.

directbool , optional

If set to True, connect the subtopologies directly with a single edge. Default is True.

directAperturesbool , optional

If set to True, connect the subtopologies directly with a single edge if they share one or more apertures. Default is False.

viaSharedTopologiesbool , optional

If set to True, connect the subtopologies via their shared topologies. Default is False.

viaSharedAperturesbool , optional

If set to True, connect the subtopologies via their shared apertures. Default is False.

toExteriorTopologiesbool , optional

If set to True, connect the subtopologies to their exterior topologies. Default is False.

toExteriorAperturesbool , optional

If set to True, connect the subtopologies to their exterior apertures. Default is False.

toContentsbool , optional

If set to True, connect the subtopologies to their contents. Default is False.

toOutpostsbool , optional

If set to True, connect the topology to the list specified in its outposts. Default is False.

idKeystr , optional

The key to use to find outpost by ID. It is case insensitive. Default is “TOPOLOGIC_ID”.

outpostsKeystr , optional

The key to use to find the list of outposts. It is case insensitive. Default is “outposts”.

vertexCategoryKeystr , optional

The key under which to store the node category. Default is “category”.

edgeCategoryKeystr , optional

The key under which to store the edge category. Default is “category”.

useInternalVertexbool , optional

If set to True, use an internal vertex to represent the subtopology. Otherwise, use its centroid. Default is False.

storeBREPbool , optional

If set to True, store the BRep of the subtopology in its representative vertex. Default is False.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

mantissaint , optional

The number of decimal places. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The created graph.

static ByTriples(triples, subjectKey: str = 'subject', predicateKey: str = 'predicate', objectKey: str = 'object', vertexIDKey: str = 'id', vertexLabelKey: str = 'label', vertexTypeKey: str = 'type', edgePredicateKey: str = 'predicate', xSpacing: float = 1.0, tolerance: float = 0.0001, silent: bool = False)

Creates a TopologicPy Graph from RDF-style triples.

Parameters
tripleslist

A list of dictionaries containing subject, predicate, and object keys.

subjectKeystr , optional

The key used to identify the triple subject. Default is “subject”.

predicateKeystr , optional

The key used to identify the triple predicate. Default is “predicate”.

objectKeystr , optional

The key used to identify the triple object. Default is “object”.

vertexIDKeystr , optional

The dictionary key used to store the vertex id. Default is “id”.

vertexLabelKeystr , optional

The dictionary key used to store the vertex label. Default is “label”.

vertexTypeKeystr , optional

The dictionary key used to store the vertex type. Default is “type”.

edgePredicateKeystr , optional

The dictionary key used to store the edge predicate. Default is “predicate”.

xSpacingfloat , optional

The spacing between generated vertices. Default is 1.0.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

A graph whose vertices represent unique subjects/objects and whose edges represent triples.

static ByVerticesEdges(vertices, edges, index: bool = True, ontology: bool = True, silent: bool = False)

Creates a graph from the input list of vertices and edges.

Parameters
verticeslist

The input list of vertices.

edgeslist

The input list of edges.

indexbool , optional

If set to True, the vertices and edges are indexed. Default is False.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The created graph.

static CardinalityReport(graph, vertexKey: str = 'id', edgeKey: str = 'predicate', predicates: list = None, direction: str = 'both', includeZero: bool = True, tolerance: float = 0.0001, silent: bool = False)

Returns a cardinality report for vertices in a graph.

This method counts how many incident edges of each selected predicate are connected to each vertex. It is useful for diagnostics such as:

  • how many spaces a door connects,

  • how many openings a wall has,

  • how many instances are defined by a type,

  • how many classifications are attached to an element.

Parameters
graphtopologic_core.Graph

The input graph.

vertexKeystr , optional

Vertex dictionary key used to identify each vertex. Default is “id”.

edgeKeystr , optional

Edge dictionary key used to identify the relationship/predicate. Default is “predicate”.

predicateslist , optional

If provided, only edges whose predicate is in this list are counted. Matching is case-insensitive. Default is None.

directionstr , optional

The edge direction to count. Options are “in”, “out”, or “both”. Default is “both”.

includeZerobool , optional

If True, include vertices with zero matching edges. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If True, suppress error and warning messages. Default is False.

Returns
list

A list of dictionaries. Each row reports the matching edge count for one vertex.

static Choice(graph, method: str = 'vertex', weightKey='length', normalize: bool = False, nxCompatible: bool = False, key: str = 'choice', colorKey='ch_color', colorScale='viridis', mantissa: int = 6, tolerance: float = 0.001, silent: bool = False)

This is an alias method for Graph.BetweenessCentrality. Returns the choice (Betweeness Centrality) of the input graph. The order of the returned list is the same as the order of vertices/edges. See https://en.wikipedia.org/wiki/Betweenness_centrality.

Parameters
graphtopologic_core.Graph

The input graph.

methodstr , optional

The method of computing the betweenness centrality. The options are “vertex” or “edge”. Default is “vertex”.

weightKeystr , optional

If specified, the value in the connected edges’ dictionary specified by the weightKey string will be aggregated to calculate the shortest path. If a numeric value cannot be retrieved from an edge, a value of 1 is used instead. This is used in weighted graphs. if weightKey is set to “Length” or “Distance”, the length of the edge will be used as its weight.

normalizebool , optional

If set to True, the values are normalized to be in the range 0 to 1. Otherwise they are not. Default is False.

nxCompatiblebool , optional

If set to True, and normalize input parameter is also set to True, the values are set to be identical to NetworkX values. Otherwise, they are normalized between 0 and 1. Default is False.

keystr , optional

The desired dictionary key under which to store the betweenness centrality score. Default is “betweenness_centrality”.

colorKeystr , optional

The desired dictionary key under which to store the betweenness centrality color. Default is “betweenness_centrality”.

colorScalestr , optional

The desired type of plotly color scales to use (e.g. “viridis”, “plasma”). Default is “viridis”. For a full list of names, see https://plotly.com/python/builtin-colorscales/. In addition to these, three color-blind friendly scales are included. These are “protanopia”, “deuteranopia”, and “tritanopia” for red, green, and blue colorblindness respectively.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The choice (betweenness centrality) of the input list of vertices within the input graph. The values are in the range 0 to 1.

static ChromaticNumber(graph, maxColors: int = 3, silent: bool = False)

Returns the chromatic number of the input graph. See https://en.wikipedia.org/wiki/Graph_coloring.

Parameters
graphtopologic_core.Graph

The input graph.

maxColorsint , optional

The desired maximum number of colors to test against. Default is 3.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
int

The chromatic number of the input graph.

static ClosenessCentrality(graph, weightKey: str = None, normalize: bool = False, nxCompatible: bool = True, useEdges: bool = False, edgeKey: str = None, angular: bool = False, angularWeightKey: str = 'angular_weight', key: str = 'closeness_centrality', colorKey: str = 'cc_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Computes the closeness centrality of the input graph. See: https://en.wikipedia.org/wiki/Closeness_centrality

Parameters
graphtopologic_core.Graph

The input graph.

weightKeystr, optional

If set to None, each edge is assumed to have a weight of 1. If set to “length” or “distance”, the geometric length of each edge is used as its weight. If set to any other value, the value associated with that key in each edge’s dictionary is used as the edge weight. Default is None.

normalizebool , optional

If set to True, the values are normalized between 0 and 1. Default is False.

nxCompatiblebool , optional

If set to True, the values are compatible with those derived from NetworkX. Default is True.

useEdgesbool , optional

If set to True, the calculation uses the edges rather than the vertices. Default is False.

edgeKeystr , optional

If not None, the value associated with that key in each edge’s dictionary is used to bundle the edges into one entity for the calculation. Otherwise, each edge segment is assumed to be an independent entity. Default is None.

angularbool , optional

If set to True, the calculation uses angular weights between adjacent edge segments. This option is valid only when useEdges is set to True. Default is False.

angularWeightKeystr , optional

The dictionary key under which to store the computed angular weight on the line graph edges. Default is “angular_weight”.

keystr , optional

The desired dictionary key name under which to store the calculated value. Default is “closeness_centrality”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “cc_color”

colorScalestr , optional

The desired colorscale name to use for colors. The default is “viridis”.

mantissa: int , optional

The desired length of the mantissa (number of digits after the decimal point). Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of centralities in the order matching the vertices or edges as requested.

static Color(graph, oldKey: str = 'color', key: str = 'color', maxColors: int = None, tolerance: float = 0.0001)

Colors the input vertices within the input graph. The saved value is an integer rather than an actual color. See Color.ByValueInRange to convert to an actual color. Any vertices that have been pre-colored will not be affected. See https://en.wikipedia.org/wiki/Graph_coloring.

Parameters
graphtopologic_core.Graph

The input graph.

oldKeystr , optional

The existing dictionary key to use to read any pre-existing color information. Default is “color”.

keystr , optional

The new dictionary key to use to write out new color information. Default is “color”.

maxColorsint , optional

The desired maximum number of colors to use. If set to None, the chromatic number of the graph is used. Default is None.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Graph

The input graph, but with its vertices colored.

static Community(graph, key: str = 'community', colorKey: str = 'cp_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Computes the best community partition of the input graph based on the Louvain method. See https://en.wikipedia.org/wiki/Louvain_method.

Parameters
graphtopologicp.Graph

The input topologic graph.

keystr , optional

The dictionary key under which to store the community partition number. Default is “community”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “cp_color”

colorScalestr , optional

The desired colorscale name to use for colors. The default is “viridis”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
——-
topologicpy.Graph

The partitioned topologic graph.

static CommunityPartition(graph, key: str = 'community', colorKey: str = 'cp_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Computes the best community partition of the input graph using the Louvain method.

Parameters
graphtopologic_core.Graph

The input graph.

keystr , optional

The dictionary key under which to store the community partition number. Default is “community”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “cp_color”.

colorScalestr , optional

The desired colorscale name to use for colors. Default is “viridis”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Included for API compatibility. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of community partition numbers ordered the same as the graph vertices.

static Compare(graphA, graphB, weightAccessibilityCentrality: float = 0.0, weightAttributes: float = 0.0, weightGeometry: float = 0.0, weightBetwennessCentrality: float = 0.0, weightClosenessCentrality: float = 0.0, weightDegreeCentrality: float = 0.0, weightDiameter: float = 0.0, weightEigenVectorCentrality: float = 0.0, weightGlobalClusteringCoefficient: float = 0.0, weightHopper: float = 0.0, weightJaccard: float = 0.0, weightPageRank: float = 0.0, weightStructure: float = 0.0, weightWeisfeilerLehman: float = 0.0, vertexIDKey: str = 'id', edgeWeightKey: str = None, wlKey: str = None, hopperKey: str = None, iterations: int = 2, maxHops: int = 2, decay: float = 0.5, mantissa: int = 6, silent: bool = False)

Compares two graphs and returns a similarity score based on attributres, geometry, metrics, structure, the Weisfeiler-Lehman graph kernel. See https://en.wikipedia.org/wiki/Weisfeiler_Leman_graph_isomorphism_test , and the weight Jaccard Similarity. See https://www.statology.org/jaccard-similarity/

Parameters
graphAtopologic Graph

The first input graph.

graphBtopologic Graph

The second input graph.

weightAccessibilityCentralityfloat , optional

The desired weight for degree accessibility similarity (graph-level and node-level). Default is 0.0.

weightAttributesfloat , optional

The desired weight for attribute similarity (dictionary key overlap at vertices). Default is 0.0.

weightBetwennessCentralityfloat , optional

The desired weight for betweenness centrality similarity (graph-level and node-level). Default is 0.0.

weightClosenessCentralityfloat , optional

The desired weight for closeness centrality similarity (graph-level and node-level). Default is 0.0.

weightDegreeCentralityfloat , optional

The desired weight for degree centrality similarity (graph-level and node-level). Default is 0.0.

weightDiameterfloat , optional

The desired weight for diameter similarity (graph-level and node-level). Default is 0.0.

weightEigenVectorCentralityfloat , optional

The desired weight for eigenvector centrality similarity (graph-level and node-level). Default is 0.0.

weightGeometryfloat , optional

The desired weight for geometric similarity (vertex positions). Default is 0.0.

weightGlobalClusteringCoefficientfloat , optional

The desired weight for global clustering coefficient similarity (graph-level and node-level). Default is 0.0.

weightHopperfloat , optional

The desired weight for Hopper kernel similarity. Default is 0.0.

weightJaccard: float , optional

The desired weight for the Weighted Jaccard similarity. Default is 0.0.

weightPageRankfloat , optional

The desired weight for PageRank similarity (graph-level and node-level). Default is 0.0.

weightStructurefloat , optional

The desired weight for structural similarity (number of vertices and edges). Default is 0.0.

weightWeisfeilerLehmanfloat , optional

The desired weight for Weisfeiler-Lehman kernel similarity (iterative label propagation). Default is 0.0.

vertexIDKey: str , optional

The dictionary key under which to find the unique vertex ID. Default is “id”.

edgeWeightKey: str , optional

The dictionary key under which to find the weight of the edge for weighted graphs. If this parameter is specified as “length” or “distance” then the length of the edge is used as its weight. The default is None which means all edges are treated as if they have a weight of 1.

wlKey: str , optional

The vertex key to use for the Weifeiler-Lehman kernel initial labels. Default is None which means it will use vertex degree as an initial label.

hopperKey: str , optional

The vertex key to use for the Hopper kernel to derive node features. Default is None which means it will use vertex degree as an initial label.

iterationsint , optional

WL kernel-specific parameter: The desired number of Weisfeiler-Lehman kernel iterations. Default is 2.

maxHopsint , optional

Hopper kernel-specific parameter: The maximum shortest-path hop distance to consider. Default is 3.

decayfloat , optional

Hopper kernel-specific parameter: A per-hop geometric decay factor in the range (0, 1]. Default is 0.5.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
dict

A dictionary of similarity scores between 0 (completely dissimilar) and 1 (identical), based on weighted components. The keys in the dictionary are: “accessibility_centrality” “attribute” “betwenness_centrality” “closeness_centrality” “degree_centrality” “eigenvector_centrality” “geometry” “global_clustering_coefficient” “hopper” “jaccard” “pagerank” “structure” “weisfeiler_lehman” “overall”

static CompiledRoutingGraph(graph, directed=None, useKDTree: bool = False, precomputeTurns: bool = False, tolerance: float = 0.0001, silent: bool = False)

Returns a compiled routing graph object from the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

directedbool , optional

If set to True, edges are treated as directed. If set to False, edges are treated as undirected. If set to None, the method attempts to read the “directed” value from the graph dictionary. Default is None.

useKDTreebool , optional

If set to True, attempts to build a KD-tree for nearest-vertex lookup. Falls back to linear search if scipy is not available. Default is False.

precomputeTurnsbool , optional

If set to True, precomputes outgoing arc lists for turn-aware routing. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, suppresses error and warning messages. Default is False.

Returns
dict

A compiled routing graph object.

static Complement(graph, ontology: bool = True, tolerance=0.0001, silent=False)

Creates the complement graph of the input graph. See https://en.wikipedia.org/wiki/Complement_graph

This version assigns an “index” key to each returned vertex and assigns “src” and “dst” keys to each created complement edge.

Parameters
graphtopologicpy.Graph

The input topologic graph.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologicpy.Graph

The created complement topologic graph.

static Complete(graph, ontology: bool = True, tolerance: float = 0.0001, silent: bool = False)

Completes the graph by conneting unconnected vertices.

Parameters
graphtopologic_core.Graph

The input graph.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologicpy.Graph

the completed graph

static Connect(graph, verticesA, verticesB, tolerance=0.0001)

Connects the two lists of input vertices.

Parameters
graphtopologic_core.Graph

The input graph.

verticesAlist

The first list of input vertices.

verticesBtopologic_core.Vertex

The second list of input vertices.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Graph

The input graph with the connected input vertices.

static ConnectedComponents(graph, key: str = 'component', tolerance: float = 0.0001, silent: bool = False)

Returns the connected components (islands) of the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

keystr , optional

The vertex and edge dictionary key under which to store the component number. Default is “component”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of connected components (island graphs). The list is sorted by the number of vertices in each component (from highest to lowest).

static Connectivity(graph, vertices=None, weightKey: str = None, normalize: bool = False, key: str = 'connectivity', colorKey: str = 'cn_color', colorScale='Viridis', mantissa: int = 6, tolerance=0.0001, silent=False)

This is an alias method for Graph.DegreeCentrality. Return the connectivity measure of the input list of vertices within the input graph. The order of the returned list is the same as the order of the input list of vertices. If no vertices are specified, the connectivity of all the vertices in the input graph is computed. See https://www.spacesyntax.online/term/connectivity/.

Parameters
graphtopologic_core.Graph

The input graph.

verticeslist , optional

The input list of vertices. Default is None which means all graph vertices are computed.

normalizebool , optional

If set to True, the values are normalized to be in the range 0 to 1. Otherwise they are not. Default is False.

weightKeystr , optional

If specified, the value in the connected edges’ dictionary specified by the weightKey string will be aggregated to calculate the vertex degree. If a numeric value cannot be retrieved from an edge, a value of 1 is used instead. This is used in weighted graphs. if weightKey is set to “Length” or “Distance”, the length of the edge will be used as its weight.

keystr , optional

The dictionary key under which to store the connectivity score. Default is “connectivity”.

colorKeystr , optional

The desired dictionary key under which to store the connectivity color. Default is “cn_color”.

colorScalestr , optional

The desired type of plotly color scales to use (e.g. “viridis”, “plasma”). Default is “viridis”. For a full list of names, see https://plotly.com/python/builtin-colorscales/. In addition to these, three color-blind friendly scales are included. These are “protanopia”, “deuteranopia”, and “tritanopia” for red, green, and blue colorblindness respectively.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The connectivity score of the input list of vertices within the input graph. The values are in the range 0 to 1 if normalized.

static ContainsEdge(graph, edge, tolerance=0.0001)

Returns True if the input graph contains the input edge. Returns False otherwise.

Parameters
graphtopologic_core.Graph

The input graph.

edgetopologic_core.Edge

The input edge.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
bool

True if the input graph contains the input edge. False otherwise.

static ContainsVertex(graph, vertex, tolerance=0.0001)

Returns True if the input graph contains the input Vertex. Returns False otherwise.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

The input Vertex.

tolerancefloat , optional

Ther desired tolerance. Default is 0.0001.

Returns
bool

True if the input graph contains the input vertex. False otherwise.

static ContractEdge(graph, edge, vertex=None, tolerance: float = 0.0001, silent: bool = False)

Contracts the input edge in the input graph into a single vertex. Please note that the dictionary of the edge is transferred to the vertex that replaces it. See https://en.wikipedia.org/wiki/Edge_contraction

Parameters
graphtopologic_core.Graph

The input graph.

edgetopologic_core.Edge

The input graph edge that needs to be contracted.

vertextopollogic.Vertex , optional

The vertex to replace the contracted edge. If set to None, the centroid of the edge is chosen. Default is None.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph, but with input edge contracted into a single vertex.

static CutVertices(graph, key: str = 'cut', silent: bool = False)

Returns the list of cut vertices in the input graph. See: https://en.wikipedia.org/wiki/Bridge_(graph_theory)

Parameters
graphtopologic_core.Graph

The input graph.

keystr , optional

The vertex dictionary key under which to store the cut status. 0 means the vertex is NOT a cut vertex. 1 means that the vertex IS a cut vertex. Default is “cut”.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of bridge edges in the input graph.

static DegreeCentrality(graph, weightKey: str = None, normalize: bool = False, nxCompatible: bool = True, useEdges: bool = False, edgeKey: str = None, key: str = 'degree_centrality', colorKey: str = 'dc_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.001, silent: bool = False)

Computes the degree centrality of the input graph. See: https://en.wikipedia.org/wiki/Centrality/

Parameters
graphtopologic_core.Graph

The input graph.

weightKeystr, optional

If set to None, each edge is assumed to have a weight of 1. If set to “length” or “distance”, the geometric length of each edge is used as its weight. If set to any other value, the value associated with that key in each edge’s dictionary is used as the edge weight. Default is None.

normalizebool , optional

If set to True, the values are normalized between 0 and 1. Default is False.

nxCompatiblebool , optional

Not used. Kept for consistency with other centrality functions. Values are always compatible with those derived from NetworkX. Default is True.

useEdgesbool , optional

If set to True, the calculation uses the edges rather than the vertices. Default is False.

edgeKeystr , optional

If not None, the value associated with that key in each edge’s dictionary is used to bundle the edges into one entity for the calculation. Otherwise, each edge segment is assumed to be an independent entity. Default is None.

keystr , optional

The desired dictionary key name under which to store the calculated value. Default is “degree_centrality”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “dc_color”

colorScalestr , optional

The desired colorscale name to use for colors. The default is “viridis”.

mantissa: int , optional

The desired length of the mantissa (number of digits after the decimal point). Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of centralities in the order matching the vertices or edges as requested.

static DegreeCentrality_old(graph, weightKey: str = None, normalize: bool = False, nxCompatible: bool = True, useEdges: bool = False, edgeKey: str = None, key: str = 'degree_centrality', colorKey='dc_color', colorScale='viridis', mantissa: int = 6, tolerance: float = 0.001, silent: bool = False)

Computes the degree centrality of the input graph. See: https://en.wikipedia.org/wiki/Centrality/

Parameters
graphtopologic_core.Graph

The input graph.

weightKeystr, optional

If set to None, each edge is assumed to have a weight of 1. If set to “length” or “distance”, the geometric length of each edge is used as its weight. If set to any other value, the value associated with that key in each edge’s dictionary is used as the edge weight. Default is None.

normalizebool , optional

If set to True, the values are normalized between 0 and 1. Default is False.

nxCompatiblebool , optional

Not used. Kept for consistency with other centrality functions. Values are always compatible with those derived from NetworkX. Default is True.

useEdgesbool , optional

If set to True, the calculation uses the edges rather than the vertices. Default is False.

edgeKeystr , optional

If not None, the value associated with that key in each edge’s dictionary is used to bundle the edges into one entity for the calculation. Otherwise, each edge segment is assumed to be an independent entity. Default is None.

keystr , optional

The desired dictionary key name under which to store the calculated value. Default is “degree_centrality”.

colorKeystr , optional

The desired dictionary key name under which to store the calculated color. Default is “dc_color”

colorScalestr , optional

The desired colorscale name to use for colors. The default is “viridis”.

mantissa: int , optional

The desired length of the mantissa (number of digits after the decimal point). Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of centralities in the order matching the vertices or edges as requested.

static DegreeMatrix(graph)

Returns the degree matrix of the input graph. See https://en.wikipedia.org/wiki/Degree_matrix.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
list

The degree matrix of the input graph.

static DegreeSequence(graph)

Returns the degree sequence of the input graph. See https://mathworld.wolfram.com/DegreeSequence.html.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
list

The degree sequence of the input graph.

static Density(graph)

Returns the density of the input graph. See https://en.wikipedia.org/wiki/Dense_graph.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
float

The density of the input graph.

static Depth(graph, vertex=None, tolerance: float = 0.0001, silent: bool = False)

Computes the maximum depth of the input graph rooted at the input vertex.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex , optional

The input root vertex. If not set, the first vertex in the graph is set as the root vertex. Default is None.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
int

The calculated maximum depth of the input graph rooted at the input vertex.

static DepthMap(graph, vertices=None, key: str = 'depth', type: str = 'topological', mantissa: int = 6, tolerance: float = 0.0001)

Return the depth map of the input list of vertices within the input graph. The returned list contains the total of the topological distances of each vertex to every other vertex in the input graph. The order of the depth map list is the same as the order of the input list of vertices. If no vertices are specified, the depth map of all the vertices in the input graph is computed.

Parameters
graphtopologic_core.Graph

The input graph.

verticeslist , optional

The input list of vertices. Default is None.

keystr , optional

The dictionary key under which to store the depth score. Default is “depth”.

typestr , optional

The type of depth distance to calculate. The options are “topological” or “metric”. Default is “topological”. See https://www.spacesyntax.online/overview-2/analysis-of-spatial-relations/.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The depth map of the input list of vertices within the input graph.

static DetachVertex(graph, *vertices, silent: bool = False)

Detaches the input vertex from its neigboring vertices.

Parameters
graphtopologic_core.Graph

The input graph.

vertices*topologic_core.Vertex

The input vertex or list of vertices.

silentbool, optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with the input vertex removed.

static Diameter(graph, silent: bool = False)

Returns the diameter of the input (unweighted, undirected) graph.

The diameter is the maximum, over all pairs of vertices, of the length of a shortest path between them. If the graph is disconnected, this returns the maximum finite eccentricity across connected components and prints a warning unless silent=True.

Parameters
graphtopologic_core.Graph

The input graph.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
int

The diameter of the input graph, or None if the graph is empty.

static Dictionary(graph)

Returns the dictionary of the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
topologic_core.Dictionary

The dictionary of the input graph.

static Difference(graphA, graphB, vertexKeys, useCentroid: bool = False, tolerance: float = 0.0001, silent: bool = False)

Intersect the two input graphs based on the input vertex keys. See https://en.wikipedia.org/wiki/Boolean_operation.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

vertexKeyslist or str , optional

The vertex dictionary key (str) or keys (list of str) to use to determine if two vertices are the same. If the vertexKeys are set to None or “loc” or “coord” or “xyz” (case insensitive), the distance between the vertices (within the tolerance) will be used to determine sameness. Default is None.

useCentroidbool , optional

This is not used here, but included for API consistency for boolean operations.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

the resultant graph. Vertex and edge dictionaries are not merged.

static Distance(graph, vertexA, vertexB, type: str = 'topological', mantissa: int = 6, tolerance: float = 0.0001)

Returns the shortest-path distance between the input vertices. See https://en.wikipedia.org/wiki/Distance_(graph_theory).

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex.

typestr , optional

The type of depth distance to calculate. The options are “topological” or “metric”. Default is “topological”. See https://www.spacesyntax.online/overview-2/analysis-of-spatial-relations/.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
float

The shortest-path metric distance between the input vertices.

static Edge(graph, vertexA, vertexB, tolerance=0.0001, silent: bool = False)

Returns the edge in the input graph that connects in the input vertices.

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input Vertex.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool, optional

If set to True, all errors and warnings are suppressed. Default is False.

Returns
topologic_core.Edge

The edge in the input graph that connects the input vertices.

static Edges(graph, vertices: list = None, strict: bool = False, sortBy: str = None, reverse: bool = False, tolerance: float = 0.0001, silent: bool = False) list

Returns the list of edges from graph whose endpoints match the given vertices according to the strict rule.

If strict is True, both endpoints of an edge must be in vertices. If strict is False, at least one endpoint must be in vertices.

Parameters
graphtopologicpy.Graph

The input graph.

verticeslist[topologicpy.Vertex]

The list of vertices to test membership against.

strictbool, optional

If set to True, require both endpoints to be in vertices. Otherwise, require at least one endpoint to be in vertices. Default is False.

sortBystr , optional

The dictionary key to use for sorting the returned edges. Special strings include “length” and “distance” to sort by the length of the edge. Default is None.

reversebool , optional

If set to True, the sorted list is reversed. This has no effect if the sortBy parameter is not set. Default is False.

silentbool, optional

If set to True, all errors and warnings are suppressed. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list[topologic_core.Edge]

The list of matching edges from the original graph (not recreated).

static EigenVectorCentrality(graph, normalize: bool = False, key: str = 'eigen_vector_centrality', colorKey: str = 'evc_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Returns the eigenvector centrality of the input graph. The order of the returned list is the same as the order of vertices.

Parameters
graphtopologic_core.Graph

The input graph.

weightKeystr, optional

Ignored in this implementation. Reserved for future use if weighted adjacency matrix is desired.

normalizebool, optional

If set to True, the centrality values are normalized to be in the range 0 to 1. Default is False.

keystr, optional

The desired dictionary key under which to store the eigenvector centrality score. Default is “eigen_vector_centrality”.

colorKeystr, optional

The desired dictionary key under which to store the eigenvector centrality color. Default is “evc_color”.

colorScalestr, optional

The desired type of Plotly color scale to use (e.g., “viridis”, “plasma”). Default is “viridis”. For a full list of names, see https://plotly.com/python/builtin-colorscales/. Also supports color-blind friendly scales: “protanopia”, “deuteranopia”, “tritanopia”.

mantissaint, optional

The desired length of the mantissa. Default is 6.

tolerancefloat, optional

The convergence tolerance for the power method. Default is 0.0001.

silentbool, optional

If set to True, suppresses all messaging and warnings. Default is False.

Returns
list

A list of eigenvector centrality values corresponding to the vertices in the input graph.

static ExportGraphToCSV(graph, path, graphLabel, graphFeatures='', graphIDHeader='graph_id', graphLabelHeader='label', graphFeaturesHeader='feat', edgeLabelKey='label', defaultEdgeLabel=0, edgeFeaturesKeys=[], edgeSRCHeader='src_id', edgeDSTHeader='dst_id', edgeLabelHeader='label', edgeFeaturesHeader='feat', edgeTrainMaskHeader='train_mask', edgeValidateMaskHeader='val_mask', edgeTestMaskHeader='test_mask', edgeMaskKey='mask', edgeTrainRatio=0.8, edgeValidateRatio=0.1, edgeTestRatio=0.1, bidirectional=True, nodeLabelKey='label', defaultNodeLabel=0, nodeFeaturesKeys=[], nodeIDHeader='node_id', nodeLabelHeader='label', nodeFeaturesHeader='feat', nodeTrainMaskHeader='train_mask', nodeValidateMaskHeader='val_mask', nodeTestMaskHeader='test_mask', nodeMaskKey='mask', nodeTrainRatio=0.8, nodeValidateRatio=0.1, nodeTestRatio=0.1, mantissa=6, tolerance=0.0001, overwrite=False)

Exports the input graph into a set of CSV files compatible with pytorch geometric.

Parameters
graphtopologic_core.Graph

The input graph

pathstr

The desired path to the output folder where the graphs, edges, and nodes CSV files will be saved.

graphLabelfloat or int

The input graph label. This can be an int (categorical) or a float (continous)

graphFeaturesstr , optional

The input graph features. This is a single string of numeric features separated by commas. Example: “3.456, 2.011, 56.4”. The defauly is “”.

graphIDHeaderstr , optional

The desired graph ID column header. Default is “graph_id”.

graphLabelHeaderstr , optional

The desired graph label column header. Default is “label”.

graphFeaturesHeaderstr , optional

The desired graph features column header. Default is “feat”.

edgeLabelKeystr , optional

The edge label dictionary key saved in each graph edge. Default is “label”.

defaultEdgeLabelint , optional

The default edge label to use if no edge label is found. Default is 0.

edgeLabelHeaderstr , optional

The desired edge label column header. Default is “label”.

edgeSRCHeaderstr , optional

The desired edge source column header. Default is “src_id”.

edgeDSTHeaderstr , optional

The desired edge destination column header. Default is “dst_id”.

edgeFeaturesHeaderstr , optional

The desired edge features column header. Default is “feat”.

edgeFeaturesKeyslist , optional

The list of feature dictionary keys saved in the dicitonaries of edges. Default is [].

edgeTrainMaskHeaderstr , optional

The desired edge train mask column header. Default is “train_mask”.

edgeValidateMaskHeaderstr , optional

The desired edge validate mask column header. Default is “val_mask”.

edgeTestMaskHeaderstr , optional

The desired edge test mask column header. Default is “test_mask”.

edgeMaskKeystr , optional

The dictionary key where the edge train, validate, test category is to be found. The value should be 0 for train 1 for validate, and 2 for test. If no key is found, the ratio of train/validate/test will be used. Default is “mask”.

edgeTrainRatiofloat , optional

The desired ratio of the edge data to use for training. The number must be between 0 and 1. Default is 0.8 which means 80% of the data will be used for training. This value is ignored if an edgeMaskKey is foud.

edgeValidateRatiofloat , optional

The desired ratio of the edge data to use for validation. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for validation. This value is ignored if an edgeMaskKey is foud.

edgeTestRatiofloat , optional

The desired ratio of the edge data to use for testing. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for testing. This value is ignored if an edgeMaskKey is foud.

bidirectionalbool , optional

If set to True, a reversed edge will also be saved for each edge in the graph. Otherwise, it will not. Default is True.

nodeFeaturesKeyslist , optional

The list of features keys saved in the dicitonaries of nodes. Default is [].

nodeLabelKeystr , optional

The node label dictionary key saved in each graph vertex. Default is “label”.

defaultNodeLabelint , optional

The default node label to use if no node label is found. Default is 0.

nodeIDHeaderstr , optional

The desired node ID column header. Default is “node_id”.

nodeLabelHeaderstr , optional

The desired node label column header. Default is “label”.

nodeFeaturesHeaderstr , optional

The desired node features column header. Default is “feat”.

nodeTrainMaskHeaderstr , optional

The desired node train mask column header. Default is “train_mask”.

nodeValidateMaskHeaderstr , optional

The desired node validate mask column header. Default is “val_mask”.

nodeTestMaskHeaderstr , optional

The desired node test mask column header. Default is “test_mask”.

nodeMaskKeystr , optional

The dictionary key where the node train, validate, test category is to be found. The value should be 0 for train 1 for validate, and 2 for test. If no key is found, the ratio of train/validate/test will be used. Default is “mask”.

nodeTrainRatiofloat , optional

The desired ratio of the node data to use for training. The number must be between 0 and 1. Default is 0.8 which means 80% of the data will be used for training. This value is ignored if an nodeMaskKey is found.

nodeValidateRatiofloat , optional

The desired ratio of the node data to use for validation. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for validation. This value is ignored if an nodeMaskKey is found.

nodeTestRatiofloat , optional

The desired ratio of the node data to use for testing. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for testing. This value is ignored if an nodeMaskKey is found.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

overwritebool , optional

If set to True, any existing files are overwritten. Otherwise, the input list of graphs is appended to the end of each file. Default is False.

Returns
bool

True if the graph has been successfully exported. False otherwise.

static ExportGraphsToCSV(graphs, path, graphLabelKey='label', defaultGraphLabel=0, graphFeaturesKeys=None, graphIDHeader='graph_id', graphLabelHeader='label', graphFeaturesHeader='feat', edgeLabelKey='label', defaultEdgeLabel=0, edgeFeaturesKeys=None, edgeSRCHeader='src_id', edgeDSTHeader='dst_id', edgeLabelHeader='label', edgeFeaturesHeader='feat', edgeTrainMaskHeader='train_mask', edgeValidateMaskHeader='val_mask', edgeTestMaskHeader='test_mask', edgeMaskKey='mask', edgeTrainRatio=0.8, edgeValidateRatio=0.1, edgeTestRatio=0.1, bidirectional=True, nodeLabelKey='label', defaultNodeLabel=0, nodeFeaturesKeys=None, nodeIDHeader='node_id', nodeLabelHeader='label', nodeFeaturesHeader='feat', nodeTrainMaskHeader='train_mask', nodeValidateMaskHeader='val_mask', nodeTestMaskHeader='test_mask', nodeMaskKey='mask', nodeTrainRatio=0.8, nodeValidateRatio=0.1, nodeTestRatio=0.1, mantissa=6, tolerance=0.0001, overwrite=False, silent=False)

Batch-export a list of TopologicPy graphs to CSV files (graphs.csv, nodes.csv, edges.csv) in a format suitable for graph ML pipelines.

Modifications vs. ExportToCSV 1. Graph labels are retrieved from the graph dictionary using graphLabelKey (fallback to defaultGraphLabel). 2. Graph features are retrieved from the graph dictionary using graphFeaturesKeys. 3. Graph/edge/node features are written as separate numeric columns:

  • Graph: graphFeaturesHeader_0 … graphFeaturesHeader_{k-1}

  • Node : nodeFeaturesHeader_0 … nodeFeaturesHeader_{k-1}

  • Edge : edgeFeaturesHeader_0 … edgeFeaturesHeader_{k-1}

Parameters
graphtopologic_core.Graph

The input graph

pathstr

The desired path to the output folder where the graphs, edges, and nodes CSV files will be saved.

graphLabelfloat or int

The input graph label. This can be an int (categorical) or a float (continous)

graphFeaturesstr , optional

The input graph features. This is a single string of numeric features separated by commas. Example: “3.456, 2.011, 56.4”. The defauly is “”.

graphIDHeaderstr , optional

The desired graph ID column header. Default is “graph_id”.

graphLabelHeaderstr , optional

The desired graph label column header. Default is “label”.

graphFeaturesHeaderstr , optional

The desired graph features column header. Default is “feat”.

edgeLabelKeystr , optional

The edge label dictionary key saved in each graph edge. Default is “label”.

defaultEdgeLabelint , optional

The default edge label to use if no edge label is found. Default is 0.

edgeLabelHeaderstr , optional

The desired edge label column header. Default is “label”.

edgeSRCHeaderstr , optional

The desired edge source column header. Default is “src_id”.

edgeDSTHeaderstr , optional

The desired edge destination column header. Default is “dst_id”.

edgeFeaturesHeaderstr , optional

The desired edge features column header. Default is “feat”.

edgeFeaturesKeyslist , optional

The list of feature dictionary keys saved in the dicitonaries of edges. Default is [].

edgeTrainMaskHeaderstr , optional

The desired edge train mask column header. Default is “train_mask”.

edgeValidateMaskHeaderstr , optional

The desired edge validate mask column header. Default is “val_mask”.

edgeTestMaskHeaderstr , optional

The desired edge test mask column header. Default is “test_mask”.

edgeMaskKeystr , optional

The dictionary key where the edge train, validate, test category is to be found. The value should be 0 for train 1 for validate, and 2 for test. If no key is found, the ratio of train/validate/test will be used. Default is “mask”.

edgeTrainRatiofloat , optional

The desired ratio of the edge data to use for training. The number must be between 0 and 1. Default is 0.8 which means 80% of the data will be used for training. This value is ignored if an edgeMaskKey is foud.

edgeValidateRatiofloat , optional

The desired ratio of the edge data to use for validation. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for validation. This value is ignored if an edgeMaskKey is foud.

edgeTestRatiofloat , optional

The desired ratio of the edge data to use for testing. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for testing. This value is ignored if an edgeMaskKey is foud.

bidirectionalbool , optional

If set to True, a reversed edge will also be saved for each edge in the graph. Otherwise, it will not. Default is True.

nodeFeaturesKeyslist , optional

The list of features keys saved in the dicitonaries of nodes. Default is [].

nodeLabelKeystr , optional

The node label dictionary key saved in each graph vertex. Default is “label”.

defaultNodeLabelint , optional

The default node label to use if no node label is found. Default is 0.

nodeIDHeaderstr , optional

The desired node ID column header. Default is “node_id”.

nodeLabelHeaderstr , optional

The desired node label column header. Default is “label”.

nodeFeaturesHeaderstr , optional

The desired node features column header. Default is “feat”.

nodeTrainMaskHeaderstr , optional

The desired node train mask column header. Default is “train_mask”.

nodeValidateMaskHeaderstr , optional

The desired node validate mask column header. Default is “val_mask”.

nodeTestMaskHeaderstr , optional

The desired node test mask column header. Default is “test_mask”.

nodeMaskKeystr , optional

The dictionary key where the node train, validate, test category is to be found. The value should be 0 for train 1 for validate, and 2 for test. If no key is found, the ratio of train/validate/test will be used. Default is “mask”.

nodeTrainRatiofloat , optional

The desired ratio of the node data to use for training. The number must be between 0 and 1. Default is 0.8 which means 80% of the data will be used for training. This value is ignored if an nodeMaskKey is found.

nodeValidateRatiofloat , optional

The desired ratio of the node data to use for validation. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for validation. This value is ignored if an nodeMaskKey is found.

nodeTestRatiofloat , optional

The desired ratio of the node data to use for testing. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for testing. This value is ignored if an nodeMaskKey is found.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

overwritebool , optional

If set to True, any existing files are overwritten. Otherwise, the input list of graphs is appended to the end of each file. Default is False.

Returns
bool

True if the graph has been successfully exported. False otherwise.

static ExportToAdjacencyMatrixCSV(adjacencyMatrix, path)

Exports the input graph into a set of CSV files compatible with pytorch geometric.

Parameters
adjacencyMatrix: list

The input adjacency matrix.

pathstr

The desired path to the output folder where the graphs, edges, and nodes CSV files will be saved.

Returns
bool

True if the graph has been successfully exported. False otherwise.

static ExportToBOT(graph, path: str, format: str = 'turtle', overwrite: bool = False, bidirectional: bool = False, includeAttributes: bool = False, includeLabel: bool = False, includeGeometry: bool = False, siteLabel: str = 'Site_0001', siteDictionary: dict = None, buildingLabel: str = 'Building_0001', buildingDictionary: dict = None, storeyPrefix: str = 'Storey', floorLevels: list = [], vertexLabelKey: str = 'label', typeKey: str = 'type', verticesKey: str = 'vertices', edgesKey: str = 'edges', edgeLabelKey: str = '', sourceKey: str = 'source', targetKey: str = 'target', xKey: str = 'hasX', yKey: str = 'hasY', zKey: str = 'hasZ', geometryKey: str = 'brep', spaceType: str = 'space', wallType: str = 'wall', slabType: str = 'slab', doorType: str = 'door', windowType: str = 'window', contentType: str = 'content', namespace: str = 'http://github.com/wassimj/topologicpy/resources', mantissa: int = 6)

Exports the input graph to an RDF graph serialized according to the BOT ontology. See https://w3c-lbd-cg.github.io/bot/.

Parameters
graphtopologic_core.Graph

The input graph.

pathstr

The desired path to where the RDF/BOT file will be saved.

formatstr , optional

The desired output format, the options are listed below. Thde default is “turtle”. turtle, ttl or turtle2 : Turtle, turtle2 is just turtle with more spacing & linebreaks xml or pretty-xml : RDF/XML, Was the default format, rdflib < 6.0.0 json-ld : JSON-LD , There are further options for compact syntax and other JSON-LD variants ntriples, nt or nt11 : N-Triples , nt11 is exactly like nt, only utf8 encoded n3 : Notation-3 , N3 is a superset of Turtle that also caters for rules and a few other things trig : Trig , Turtle-like format for RDF triples + context (RDF quads) and thus multiple graphs trix : Trix , RDF/XML-like format for RDF quads nquads : N-Quads , N-Triples-like format for RDF quads

overwritebool , optional

If set to True, any existing file is overwritten. Otherwise, it is not. Default is False.

bidirectionalbool , optional

If set to True, reverse relationships are created wherever possible. Otherwise, they are not. Default is False.

includeAttributesbool , optional

If set to True, the attributes associated with vertices in the graph are written out. Otherwise, they are not. Default is False.

includeLabelbool , optional

If set to True, a label is attached to each node. Otherwise, it is not. Default is False.

includeGeometrybool , optional

If set to True, the geometry associated with vertices in the graph are written out. Otherwise, they are not. Default is False.

siteLabelstr , optional

The desired site label. Default is “Site_0001”.

siteDictionarydict , optional

The dictionary of site attributes to include in the output. Default is None.

buildingLabelstr , optional

The desired building label. Default is “Building_0001”.

buildingDictionarydict , optional

The dictionary of building attributes to include in the output. Default is None.

storeyPrefixstr , optional

The desired prefixed to use for each building storey. Default is “Storey”.

floorLevelslist , optional

The list of floor levels. This should be a numeric list, sorted from lowest to highest. If not provided, floorLevels will be computed automatically based on the vertices’ (zKey)) attribute. See below.

verticesKeystr , optional

The desired key name to call vertices. Default is “vertices”.

edgesKeystr , optional

The desired key name to call edges. Default is “edges”.

vertexLabelKeystr , optional

If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number. Note: If vertex labels are not unique, they will be forced to be unique.

edgeLabelKeystr , optional

If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number. Note: If edge labels are not unique, they will be forced to be unique.

sourceKeystr , optional

The dictionary key used to store the source vertex. Default is “source”.

targetKeystr , optional

The dictionary key used to store the target vertex. Default is “target”.

xKeystr , optional

The desired key name to use for x-coordinates. Default is “hasX”.

yKeystr , optional

The desired key name to use for y-coordinates. Default is “hasY”.

zKeystr , optional

The desired key name to use for z-coordinates. Default is “hasZ”.

geometryKeystr , optional

The desired key name to use for geometry. Default is “brep”.

typeKeystr , optional

The dictionary key to use to look up the type of the node. Default is “type”.

geometryKeystr , optional

The dictionary key to use to look up the geometry of the node. Default is “brep”.

spaceTypestr , optional

The dictionary string value to use to look up vertices of type “space”. Default is “space”.

wallTypestr , optional

The dictionary string value to use to look up vertices of type “wall”. Default is “wall”.

slabTypestr , optional

The dictionary string value to use to look up vertices of type “slab”. Default is “slab”.

doorTypestr , optional

The dictionary string value to use to look up vertices of type “door”. Default is “door”.

windowTypestr , optional

The dictionary string value to use to look up vertices of type “window”. Default is “window”.

contentTypestr , optional

The dictionary string value to use to look up vertices of type “content”. Default is “contents”.

namespacestr , optional

The desired namespace to use in the BOT graph. Default is “http://github.com/wassimj/topologicpy/resources”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
str

The rdf graph serialized string using the BOT ontology.

static ExportToCSV(graph, path, graphLabelKey='label', defaultGraphLabel=0, graphFeaturesKeys=None, graphIDHeader='graph_id', graphLabelHeader='label', graphFeaturesHeader='feat', edgeLabelKey='label', defaultEdgeLabel=0, edgeFeaturesKeys=None, edgeSRCHeader='src_id', edgeDSTHeader='dst_id', edgeLabelHeader='label', edgeFeaturesHeader='feat', edgeTrainMaskHeader='train_mask', edgeValidateMaskHeader='val_mask', edgeTestMaskHeader='test_mask', edgeMaskKey='mask', edgeTrainRatio=0.8, edgeValidateRatio=0.1, edgeTestRatio=0.1, bidirectional=True, nodeLabelKey='label', defaultNodeLabel=0, nodeFeaturesKeys=None, nodeIDHeader='node_id', nodeLabelHeader='label', nodeFeaturesHeader='feat', nodeTrainMaskHeader='train_mask', nodeValidateMaskHeader='val_mask', nodeTestMaskHeader='test_mask', nodeMaskKey='mask', nodeTrainRatio=0.8, nodeValidateRatio=0.1, nodeTestRatio=0.1, mantissa=6, tolerance=0.0001, overwrite=False, silent=False)

Exports the input graph into a set of CSV files compatible with pytorch geometric.

Parameters
graphtopologic_core.Graph or list of graphs.

The input graph or graphs

pathstr

The desired path to the output folder where the graphs, edges, and nodes CSV files will be saved.

graphLabelKeystr , optional

The graph label dictionary key saved in each graph. Default is “label”.

defaultGraphLabelint , optional

The default graph label to use if no graph label is found. Default is 0.

graphFeaturesKeyslist , optional

The list of feature dictionary keys saved in the dicitonaries of graphs. Default is None.

graphIDHeaderstr , optional

The desired graph ID column header. Default is “graph_id”.

graphLabelHeaderstr , optional

The desired graph label column header. Default is “label”.

graphFeaturesHeaderstr , optional

The desired graph features column header. Default is “feat”.

edgeLabelKeystr , optional

The edge label dictionary key saved in each graph edge. Default is “label”.

defaultEdgeLabelint , optional

The default edge label to use if no edge label is found. Default is 0.

edgeLabelHeaderstr , optional

The desired edge label column header. Default is “label”.

edgeSRCHeaderstr , optional

The desired edge source column header. Default is “src_id”.

edgeDSTHeaderstr , optional

The desired edge destination column header. Default is “dst_id”.

edgeFeaturesHeaderstr , optional

The desired edge features column header. Default is “feat”.

edgeFeaturesKeyslist , optional

The list of feature dictionary keys saved in the dicitonaries of edges. Default is None.

edgeTrainMaskHeaderstr , optional

The desired edge train mask column header. Default is “train_mask”.

edgeValidateMaskHeaderstr , optional

The desired edge validate mask column header. Default is “val_mask”.

edgeTestMaskHeaderstr , optional

The desired edge test mask column header. Default is “test_mask”.

edgeMaskKeystr , optional

The dictionary key where the edge train, validate, test category is to be found. The value should be 0 for train 1 for validate, and 2 for test. If no key is found, the ratio of train/validate/test will be used. Default is “mask”.

edgeTrainRatiofloat , optional

The desired ratio of the edge data to use for training. The number must be between 0 and 1. Default is 0.8 which means 80% of the data will be used for training. This value is ignored if an edgeMaskKey is foud.

edgeValidateRatiofloat , optional

The desired ratio of the edge data to use for validation. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for validation. This value is ignored if an edgeMaskKey is foud.

edgeTestRatiofloat , optional

The desired ratio of the edge data to use for testing. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for testing. This value is ignored if an edgeMaskKey is foud.

bidirectionalbool , optional

If set to True, a reversed edge will also be saved for each edge in the graph. Otherwise, it will not. Default is True.

nodeFeaturesKeyslist , optional

The list of features keys saved in the dicitonaries of nodes. Default is None.

nodeLabelKeystr , optional

The node label dictionary key saved in each graph vertex. Default is “label”.

defaultNodeLabelint , optional

The default node label to use if no node label is found. Default is 0.

nodeIDHeaderstr , optional

The desired node ID column header. Default is “node_id”.

nodeLabelHeaderstr , optional

The desired node label column header. Default is “label”.

nodeFeaturesHeaderstr , optional

The desired node features column header. Default is “feat”.

nodeTrainMaskHeaderstr , optional

The desired node train mask column header. Default is “train_mask”.

nodeValidateMaskHeaderstr , optional

The desired node validate mask column header. Default is “val_mask”.

nodeTestMaskHeaderstr , optional

The desired node test mask column header. Default is “test_mask”.

nodeMaskKeystr , optional

The dictionary key where the node train, validate, test category is to be found. The value should be 0 for train 1 for validate, and 2 for test. If no key is found, the ratio of train/validate/test will be used. Default is “mask”.

nodeTrainRatiofloat , optional

The desired ratio of the node data to use for training. The number must be between 0 and 1. Default is 0.8 which means 80% of the data will be used for training. This value is ignored if an nodeMaskKey is found.

nodeValidateRatiofloat , optional

The desired ratio of the node data to use for validation. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for validation. This value is ignored if an nodeMaskKey is found.

nodeTestRatiofloat , optional

The desired ratio of the node data to use for testing. The number must be between 0 and 1. Default is 0.1 which means 10% of the data will be used for testing. This value is ignored if an nodeMaskKey is found.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

overwritebool , optional

If set to True, any existing files are overwritten. Otherwise, the input list of graphs is appended to the end of each file. Default is False.

silentbool , optional

If set to True no warnings or errors are printed. Default is False.

Returns
——-
bool

True if the graph has been successfully exported. False otherwise.

static ExportToGEXF(graph, path: str = None, graphWidth: float = 20, graphLength: float = 20, graphHeight: float = 20, defaultVertexColor: str = 'black', defaultVertexSize: float = 3, vertexLabelKey: str = None, vertexColorKey: str = None, vertexSizeKey: str = None, defaultEdgeColor: str = 'black', defaultEdgeWeight: float = 1, defaultEdgeType: str = 'undirected', edgeLabelKey: str = None, edgeColorKey: str = None, edgeWeightKey: str = None, overwrite: bool = False, mantissa: int = 6, tolerance: float = 0.0001)

Exports the input graph to a Graph Exchange XML (GEXF) file format. See https://gexf.net/

Parameters
graphtopologic_core.Graph

The input graph

pathstr

The desired path to the output folder where the graphs, edges, and nodes CSV files will be saved.

graphWidthfloat or int , optional

The desired graph width. Default is 20.

graphLengthfloat or int , optional

The desired graph length. Default is 20.

graphHeightfloat or int , optional

The desired graph height. Default is 20.

defaultVertexColorstr , optional

The desired default vertex color. Default is “black”.

defaultVertexSizefloat or int , optional

The desired default vertex size. Default is 3.

defaultEdgeColorstr , optional

The desired default edge color. Default is “black”.

defaultEdgeWeightfloat or int , optional

The desired default edge weight. The edge weight determines the width of the displayed edge. Default is 3.

defaultEdgeTypestr , optional

The desired default edge type. This can be one of “directed” or “undirected”. Default is “undirected”.

vertexLabelKeystr , optional

If specified, the vertex dictionary is searched for this key to determine the vertex label. If not specified the vertex label being is set to “Node X” where is X is a unique number. Default is None.

vertexColorKeystr , optional

If specified, the vertex dictionary is searched for this key to determine the vertex color. If not specified the vertex color is set to the value defined by defaultVertexColor parameter. Default is None.

vertexSizeKeystr , optional

If specified, the vertex dictionary is searched for this key to determine the vertex size. If not specified the vertex size is set to the value defined by defaultVertexSize parameter. Default is None.

edgeLabelKeystr , optional

If specified, the edge dictionary is searched for this key to determine the edge label. If not specified the edge label being is set to “Edge X” where is X is a unique number. Default is None.

edgeColorKeystr , optional

If specified, the edge dictionary is searched for this key to determine the edge color. If not specified the edge color is set to the value defined by defaultEdgeColor parameter. Default is None.

edgeWeightKeystr , optional

If specified, the edge dictionary is searched for this key to determine the edge weight. If not specified the edge weight is set to the value defined by defaultEdgeWeight parameter. Default is None.

overwritebool , optional

If set to True, any existing file is overwritten. Otherwise, it is not. Default is False.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
bool

True if the graph has been successfully exported. False otherwise.

static ExportToGraphVizGraph(graph, path, device='svg_inline', deviceKey=None, scale=1, scaleKey=None, directed=False, directedKey=None, layout='dot', layoutKey=None, rankDir='TB', rankDirKey=None, bgColor='white', bgColorKey=None, fontName='Arial', fontNameKey=None, fontSize=12, fontSizeKey=None, vertexSep=0.5, vertexSepKey=None, rankSep=0.5, rankSepKey=None, splines='True', splinesKey=None, showGraphLabel=False, graphLabel='', graphLabelKey=None, graphLabelLoc='t', graphLabelLocKey=None, showVertexLabel=False, vertexLabelPrefix='', vertexLabelKey=None, vertexWidth=0.5, vertexWidthKey=None, vertexHeight=0.5, vertexHeightKey=None, vertexFixedSize=False, vertexFixedSizeKey=None, vertexShape='circle', vertexShapeKey=None, vertexStyle='filled', vertexStyleKey=None, vertexFillColor='lightgray', vertexFillColorKey=None, vertexColor='black', vertexColorKey=None, vertexFontColor='black', vertexFontColorKey=None, showEdgeLabel=False, edgeLabelPrefix='', edgeLabelKey=None, edgeColor='black', edgeColorKey=None, edgeWidth=1, edgeWidthKey=None, edgeStyle='solid', edgeStyleKey=None, edgeArrowhead='normal', edgeArrowheadKey=None, edgeFontColor='black', edgeFontColorKey=None, overwrite=False, silent=False)

Exports the input graph to a GraphViz .gv (dot) file.

Parameters
graphtopologic_core.Graph

The input graph.

pathstr

The path to the output file (e.g., “output.gv”).

devicestr, optional

The output format device, such as ‘svg_inline’, ‘pdf’, or ‘png’. Default is ‘svg_inline’.

deviceKeystr, optional

Dictionary key to override the device value. Default is None.

scalefloat, optional

Global scaling factor. Default is 1.

scaleKeystr, optional

Dictionary key to override the scale per-graph. Default is None.

directedbool, optional

Whether to treat the graph as directed. Default is False.

directedKeystr, optional

Dictionary key to override the directed flag per-graph. Default is None.

layoutstr, optional

Layout engine to use. Options include ‘dot’, ‘circo’, ‘fdp’, ‘neato’, ‘osage’, ‘sfdp’, etc. Default is ‘dot’.

layoutKeystr, optional

Dictionary key to override the layout per-graph. Default is None.

rankDirstr, optional

Direction of graph ranking. Options: ‘TB’ (top-bottom), ‘LR’ (left-right), ‘RL’, ‘BT’. Default is ‘TB’.

rankDirKeystr, optional

Dictionary key to override rankDir per-graph. Default is None.

bgColorstr, optional

Background color. Default is ‘white’.

bgColorKeystr, optional

Dictionary key to override bgColor. Default is None.

fontNamestr, optional

Name of the font to use for all text. Default is ‘Arial’.

fontNameKeystr, optional

Dictionary key to override fontName. Default is None.

fontSizeint or float, optional

Size of font in points. Default is 12.

fontSizeKeystr, optional

Dictionary key to override fontSize. Default is None.

vertexSepfloat, optional

Minimum separation between vertices. Default is 0.5.

vertexSepKeystr, optional

Dictionary key to override vertexSep. Default is None.

rankSepfloat, optional

Separation between ranks. Default is 0.5.

rankSepKeystr, optional

Dictionary key to override rankSep. Default is None.

splinesstr, optional

Whether to use spline edges. Can be ‘true’, ‘false’, or ‘polyline’. Default is ‘True’.

splinesKeystr, optional

Dictionary key to override splines. Default is None.

showGraphLabelbool, optional

Whether to show a label for the whole graph. Default is False.

graphLabelstr, optional

Text for the graph label. Default is an empty string.

graphLabelKeystr, optional

Dictionary key to override graphLabel. Default is None.

graphLabelLocstr, optional

Position of the graph label: ‘t’ (top), ‘b’ (bottom), ‘c’ (center). Default is ‘t’.

graphLabelLocKeystr, optional

Dictionary key to override graphLabelLoc. Default is None.

showVertexLabelbool, optional

Whether to display vertex labels. Default is False.

vertexLabelPrefixstr, optional

Text prefix for vertex labels. Default is empty string.

vertexLabelKeystr, optional

Dictionary key used to retrieve label text from vertex dictionary. Default is None.

vertexWidthfloat, optional

Width of each vertex. Default is 0.5.

vertexWidthKeystr, optional

Dictionary key to override vertexWidth. Default is None.

vertexHeightfloat, optional

Height of each vertex. Default is 0.5.

vertexHeightKeystr, optional

Dictionary key to override vertexHeight. Default is None.

vertexFixedSizebool, optional

Whether vertices should be fixed in size. Default is False.

vertexFixedSizeKeystr, optional

Dictionary key to override vertexFixedSize. Default is None.

vertexShapestr, optional

Shape of the vertex (‘circle’, ‘ellipse’, ‘box’, etc.). Default is ‘circle’.

vertexShapeKeystr, optional

Dictionary key to override vertexShape. Default is None.

vertexStylestr, optional

Style of vertex (e.g., ‘filled’, ‘dashed’). Default is ‘filled’.

vertexStyleKeystr, optional

Dictionary key to override vertexStyle. Default is None.

vertexFillColorstr, optional

Fill color for vertices. Default is ‘lightgray’.

vertexFillColorKeystr, optional

Dictionary key to override vertexFillColor. Default is None.

vertexColorstr, optional

Border color for vertices. Default is ‘black’.

vertexColorKeystr, optional

Dictionary key to override vertexColor. Default is None.

vertexFontColorstr, optional

Font color for vertex labels. Default is ‘black’.

vertexFontColorKeystr, optional

Dictionary key to override vertexFontColor. Default is None.

showEdgeLabelbool, optional

Whether to display edge labels. Default is False.

edgeLabelPrefixstr, optional

Text prefix for edge labels. Default is empty string.

edgeLabelKeystr, optional

Dictionary key used to retrieve label text from edge dictionary. Default is None.

edgeColorstr, optional

Color of edges. Default is ‘black’.

edgeColorKeystr, optional

Dictionary key to override edgeColor. Default is None.

edgeWidthfloat, optional

Width (thickness) of edges. Default is 1.

edgeWidthKeystr, optional

Dictionary key to override edgeWidth. Default is None.

edgeStylestr, optional

Style of the edge line (e.g., ‘solid’, ‘dashed’). Default is ‘solid’.

edgeStyleKeystr, optional

Dictionary key to override edgeStyle. Default is None.

edgeArrowheadstr, optional

Arrowhead style for directed edges. Default is ‘normal’.

edgeArrowheadKeystr, optional

Dictionary key to override edgeArrowhead. Default is None.

edgeFontColorstr, optional

Font color for edge labels. Default is ‘black’.

edgeFontColorKeystr, optional

Dictionary key to override edgeFontColor. Default is None.

overwritebool, optional

If True, overwrites existing files at the given path. Default is False.

silentbool, optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
bool

True if the graph was successfully exported. False otherwise.

static ExportToJSON(graph, path, propertiesKey='properties', verticesKey='vertices', edgesKey='edges', vertexLabelKey='', edgeLabelKey='', xKey='x', yKey='y', zKey='z', indent=4, sortKeys=False, mantissa=6, overwrite=False)

Exports the input graph to a JSON file.

Parameters
graphtopologic_core.Graph

The input graph.

pathstr

The path to the JSON file.

propertiesKeystr , optional

The desired key name to call graph properties. Default is “properties”.

verticesKeystr , optional

The desired key name to call vertices. Default is “vertices”.

edgesKeystr , optional

The desired key name to call edges. Default is “edges”.

vertexLabelKeystr , optional

If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number. Note: If vertex labels are not unique, they will be forced to be unique.

edgeLabelKeystr , optional

If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number. Note: If edge labels are not unique, they will be forced to be unique.

xKeystr , optional

The desired key name to use for x-coordinates. Default is “x”.

yKeystr , optional

The desired key name to use for y-coordinates. Default is “y”.

zKeystr , optional

The desired key name to use for z-coordinates. Default is “z”.

indentint , optional

The desired amount of indent spaces to use. Default is 4.

sortKeysbool , optional

If set to True, the keys will be sorted. Otherwise, they won’t be. Default is False.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

overwritebool , optional

If set to True the ouptut file will overwrite any pre-existing file. Otherwise, it won’t. Default is False.

Returns
bool

The status of exporting the JSON file. If True, the operation was successful. Otherwise, it was unsuccesful.

static ExportToJSONLD(graph, path, context=None, verticesKey='nodes', edgesKey='edges', labelKey='label', sourceKey='source', targetKey='target', categoryKey='category', xKey='x', yKey='y', zKey='z', indent=2, sortKeys=False, mantissa=6, overwrite=False)

Exports the input graph to a JSON file.

Parameters
graphtopologic_core.Graph

The input graph.

pathstr

The path to the JSON file.

verticesKeystr , optional

The desired key name to call vertices. Default is “vertices”.

edgesKeystr , optional

The desired key name to call edges. Default is “edges”.

vertexLabelKeystr , optional

If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number. Note: If vertex labels are not unique, they will be forced to be unique.

edgeLabelKeystr , optional

If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number. Note: If edge labels are not unique, they will be forced to be unique.

xKeystr , optional

The desired key name to use for x-coordinates. Default is “x”.

yKeystr , optional

The desired key name to use for y-coordinates. Default is “y”.

zKeystr , optional

The desired key name to use for z-coordinates. Default is “z”.

indentint , optional

The desired amount of indent spaces to use. Default is 4.

sortKeysbool , optional

If set to True, the keys will be sorted. Otherwise, they won’t be. Default is False.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

overwritebool , optional

If set to True the ouptut file will overwrite any pre-existing file. Otherwise, it won’t. Default is False.

Returns
bool

The status of exporting the JSON file. If True, the operation was successful. Otherwise, it was unsuccesful.

static ExportToRDF(graph, path: str, subjectKey: str = 'id', predicateKey: str = 'predicate', objectKey: str = 'id', baseIRI: str = 'https://topologic.app/resource/', ontologyIRI: str = 'http://w3id.org/topologicpy#', includeMetadata: bool = True, format: str = 'turtle', overwrite: bool = True, tolerance: float = 0.0001, silent: bool = False)

Exports a TopologicPy Graph to an RDF/Turtle file.

Parameters
graphtopologic_core.Graph

The input graph.

pathstr

The output file path. A .ttl extension is recommended.

subjectKeystr , optional

Vertex dictionary key used to identify RDF subjects. Default is “id”.

predicateKeystr , optional

Edge dictionary key used to identify RDF predicates. Default is “predicate”.

objectKeystr , optional

Vertex dictionary key used to identify RDF objects. Default is “id”.

baseIRIstr , optional

Base IRI for generated resources. Default is “https://topologic.app/resource/”.

ontologyIRIstr , optional

Base IRI for generated predicates/classes. Default is “http://w3id.org/topologicpy#”.

includeMetadatabool , optional

If True, vertex labels, types, and selected dictionary values are exported. Default is True.

formatstr , optional

Currently only “turtle” is supported. Default is “turtle”.

overwritebool , optional

If True, overwrite an existing output file. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If True, suppresses error and warning messages. Default is False.

Returns
str

The output file path if export succeeds. Returns None otherwise.

static ExportToWiki(graph, path: str, vertexKey: str = 'id', vertexLabelKey: str = 'label', vertexTypeKey: str = 'type', edgeKey: str = 'predicate', titleKey: str = None, includeDictionaries: bool = True, includeBacklinks: bool = True, overwrite: bool = True, tolerance: float = 0.0001, silent: bool = False)

Exports a TopologicPy Graph as an Obsidian-style markdown wiki.

Each graph vertex is exported as one markdown file. Graph edges are exported as wikilinks between the generated markdown files.

Parameters
graphtopologic_core.Graph

The input graph.

pathstr

The folder path where markdown files will be written.

vertexKeystr , optional

Vertex dictionary key used as the stable page identifier. Default is “id”.

vertexLabelKeystr , optional

Vertex dictionary key used as the human-readable label. Default is “label”.

vertexTypeKeystr , optional

Vertex dictionary key used as the entity type. Default is “type”.

edgeKeystr , optional

Edge dictionary key used as the relationship/predicate label. Default is “predicate”.

titleKeystr , optional

Optional vertex dictionary key to use as the page title. If None, the title is derived from vertexLabelKey, vertexKey, or index. Default is None.

includeDictionariesbool , optional

If True, vertex dictionaries are written as property sections. Default is True.

includeBacklinksbool , optional

If True, incoming relations are also listed. Default is True.

overwritebool , optional

If True, existing markdown files with matching names are overwritten. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If True, suppresses error and warning messages. Default is False.

Returns
list

A list of written markdown file paths. Returns None if export fails.

static FiedlerVector(graph, mantissa=6, silent: bool = False)

Computes the Fiedler vector of a graph. See https://en.wikipedia.org/wiki/Algebraic_connectivity.

Parameters
graphtopologic_core.Graph

The input graph

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The Fiedler vector (eigenvector corresponding to the second smallest eigenvalue).

static FiedlerVectorPartition(graph, key='partition', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Partitions the input graph based on FiedlerVector method. See https://en.wikipedia.org/wiki/Graph_partition.

Parameters
graphtopologicp.Graph

The input topologic graph.

keystr , optional

The vertex and edge dictionary key under which to store the parition number. Default is “partition”. Valid partition numbers start from 1. Cut edges receive a partition number of 0.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologicpy.Graph

The partitioned topologic graph.

static GlobalClusteringCoefficient(graph)

Returns the global clustering coefficient of the input graph. See https://en.wikipedia.org/wiki/Clustering_coefficient.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
int

The computed global clustering coefficient.

static GraphVizGraph(graph, device='svg_inline', deviceKey=None, scale=1, scaleKey=None, directed=False, directedKey=None, layout='dot', layoutKey=None, rankDir='TB', rankDirKey=None, bgColor='white', bgColorKey=None, fontName='Arial', fontNameKey=None, fontSize=12, fontSizeKey=None, vertexSep=0.5, vertexSepKey=None, rankSep=0.5, rankSepKey=None, splines='true', splinesKey=None, showGraphLabel=False, graphLabel='', graphLabelKey=None, graphLabelLoc='t', graphLabelLocKey=None, showVertexLabel=False, vertexLabelPrefix='', vertexLabelKey=None, vertexWidth=0.5, vertexWidthKey=None, vertexHeight=0.5, vertexHeightKey=None, vertexFixedSize=False, vertexFixedSizeKey=None, vertexShape='circle', vertexShapeKey=None, vertexStyle='filled', vertexStyleKey=None, vertexFillColor='lightgray', vertexFillColorKey=None, vertexColor='black', vertexColorKey=None, vertexFontColor='black', vertexFontColorKey=None, showEdgeLabel=False, edgeLabelPrefix='', edgeLabelKey=None, edgeColor='black', edgeColorKey=None, edgeWidth=1, edgeWidthKey=None, edgeStyle='solid', edgeStyleKey=None, edgeArrowhead='normal', edgeArrowheadKey=None, edgeFontColor='black', edgeFontColorKey=None, silent=False)

Converts the input graph to a GraphViz graph. GraphViz should be installed separately, using your system’s package manager.

Parameters
graphtopologic_core.Graph

The input graph.

devicestr, optional

The output format device, such as ‘svg_inline’, ‘pdf’, or ‘png’. Default is ‘svg_inline’.

deviceKeystr, optional

Dictionary key to override the device value. Default is None.

scalefloat, optional

Global scaling factor. Default is 1.

scaleKeystr, optional

Dictionary key to override the scale per-graph. Default is None.

directedbool, optional

Whether to treat the graph as directed. Default is False.

directedKeystr, optional

Dictionary key to override the directed flag per-graph. Default is None.

layoutstr, optional

Layout engine to use. Options include ‘dot’, ‘circo’, ‘fdp’, ‘neato’, ‘osage’, ‘sfdp’, etc. Default is ‘dot’.

layoutKeystr, optional

Dictionary key to override the layout per-graph. Default is None.

rankDirstr, optional

Direction of graph ranking. Options: ‘TB’ (top-bottom), ‘LR’ (left-right), ‘RL’, ‘BT’. Default is ‘TB’.

rankDirKeystr, optional

Dictionary key to override rankDir per-graph. Default is None.

bgColorstr, optional

Background color. Default is ‘white’.

bgColorKeystr, optional

Dictionary key to override bgColor. Default is None.

fontNamestr, optional

Name of the font to use for all text. Default is ‘Arial’.

fontNameKeystr, optional

Dictionary key to override fontName. Default is None.

fontSizeint or float, optional

Size of font in points. Default is 12.

fontSizeKeystr, optional

Dictionary key to override fontSize. Default is None.

vertexSepfloat, optional

Minimum separation between vertices. Default is 0.5.

vertexSepKeystr, optional

Dictionary key to override vertexSep. Default is None.

rankSepfloat, optional

Separation between ranks. Default is 0.5.

rankSepKeystr, optional

Dictionary key to override rankSep. Default is None.

splinesstr, optional

Whether to use spline edges. Can be ‘true’, ‘false’, or ‘polyline’. Default is ‘True’.

splinesKeystr, optional

Dictionary key to override splines. Default is None.

showGraphLabelbool, optional

Whether to show a label for the whole graph. Default is False.

graphLabelstr, optional

Text for the graph label. Default is an empty string.

graphLabelKeystr, optional

Dictionary key to override graphLabel. Default is None.

graphLabelLocstr, optional

Position of the graph label: ‘t’ (top), ‘b’ (bottom), ‘c’ (center). Default is ‘t’.

graphLabelLocKeystr, optional

Dictionary key to override graphLabelLoc. Default is None.

showVertexLabelbool, optional

Whether to display vertex labels. Default is False.

vertexLabelPrefixstr, optional

Text prefix for vertex labels. Default is empty string.

vertexLabelKeystr, optional

Dictionary key used to retrieve label text from vertex dictionary. Default is None.

vertexWidthfloat, optional

Width of each vertex. Default is 0.5.

vertexWidthKeystr, optional

Dictionary key to override vertexWidth. Default is None.

vertexHeightfloat, optional

Height of each vertex. Default is 0.5.

vertexHeightKeystr, optional

Dictionary key to override vertexHeight. Default is None.

vertexFixedSizebool, optional

Whether vertices should be fixed in size. Default is False.

vertexFixedSizeKeystr, optional

Dictionary key to override vertexFixedSize. Default is None.

vertexShapestr, optional

Shape of the vertex (‘circle’, ‘ellipse’, ‘box’, etc.). Default is ‘circle’.

vertexShapeKeystr, optional

Dictionary key to override vertexShape. Default is None.

vertexStylestr, optional

Style of vertex (e.g., ‘filled’, ‘dashed’). Default is ‘filled’.

vertexStyleKeystr, optional

Dictionary key to override vertexStyle. Default is None.

vertexFillColorstr, optional

Fill color for vertices. Default is ‘lightgray’.

vertexFillColorKeystr, optional

Dictionary key to override vertexFillColor. Default is None.

vertexColorstr, optional

Border color for vertices. Default is ‘black’.

vertexColorKeystr, optional

Dictionary key to override vertexColor. Default is None.

vertexFontColorstr, optional

Font color for vertex labels. Default is ‘black’.

vertexFontColorKeystr, optional

Dictionary key to override vertexFontColor. Default is None.

showEdgeLabelbool, optional

Whether to display edge labels. Default is False.

edgeLabelPrefixstr, optional

Text prefix for edge labels. Default is empty string.

edgeLabelKeystr, optional

Dictionary key used to retrieve label text from edge dictionary. Default is None.

edgeColorstr, optional

Color of edges. Default is ‘black’.

edgeColorKeystr, optional

Dictionary key to override edgeColor. Default is None.

edgeWidthfloat, optional

Width (thickness) of edges. Default is 1.

edgeWidthKeystr, optional

Dictionary key to override edgeWidth. Default is None.

edgeStylestr, optional

Style of the edge line (e.g., ‘solid’, ‘dashed’). Default is ‘solid’.

edgeStyleKeystr, optional

Dictionary key to override edgeStyle. Default is None.

edgeArrowheadstr, optional

Arrowhead style for directed edges. Default is ‘normal’.

edgeArrowheadKeystr, optional

Dictionary key to override edgeArrowhead. Default is None.

edgeFontColorstr, optional

Font color for edge labels. Default is ‘black’.

edgeFontColorKeystr, optional

Dictionary key to override edgeFontColor. Default is None.

overwritebool, optional

If True, overwrites existing files at the given path. Default is False.

silentbool, optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
graphviz.graphs.Graph

The created GraphViz graph.

static Guid(graph)

Returns the guid of the input graph

Parameters
graphtopologic_core.Graph

The input graph.

static HasseDiagram(topology, types=['vertex', 'edge', 'wire', 'face', 'shell', 'cell', 'cellComplex'], topDown: bool = False, minDistance: float = 0.1, vertexLabelKey: str = 'label', vertexTypeKey: str = 'type', vertexColorKey: str = 'color', colorScale: str = 'viridis', storeBREP: bool = False, tolerance: float = 0.0001, silent: bool = False)

Constructs a Hasse diagram from the input topology as a directed graph. See: https://en.wikipedia.org/wiki/Hasse_diagram Vertices represent topologies (vertices, edges, wires, faces, shells, cells, cellComplexes). Edges represent inclusion (e.g. vertex ⊂ edge, edge ⊂ wire).

Parameters
topologytopologic_core.Topology

The input topology

typesoptional, list

The list of topology types that you wish to encode in the Hasse diagram. This list must be ordered according to topologic_core’s class hierarchy. If you are not interested in representing some topology types. These can be omitted. The default is: [“vertex”, “edge”, “wire”, “face”, “shell”, “cell”, “cellComplex”].

topDownbool , optional

If set to True, the graph edges are directed from topologies to their subtopologies. Otherwise, they are directed from topologies to their supertopologies. Default is False.

minDistancefloat , optional

The desired minimum distance between the vertices of the graph. Default is 0.1.

vertexLabelKey: str , optional

The desired vertex dictionary key under which to store a unique label (of the form Type_Index). Default is “label”.

vertexTypeKey: str , optional

The desired vertex dictionary key under which to store the topology type (e.g. “vertex”, “edge”, “wire”). Default is “type”.

vertexColorKey: str , optional

The desired vertex dictionary key under which to store the topology color. Default is “color”.

colorScalestr , optional

The desired type of plotly color scales to use (e.g. “viridis”, “plasma”). Default is “viridis”. For a full list of names, see https://plotly.com/python/builtin-colorscales/. In addition to these, three color-blind friendly scales are included. These are “protanopia”, “deuteranopia”, and “tritanopia” for red, green, and blue colorblindness respectively.

storeBREPbool , optional

If set to True, store the BRep of the topology in its representative vertex. Default is False.

tolerancefloat

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The created Hesse diagram graph.

static HopperKernel(graphA, graphB, key: str = None, maxHops: int = 3, decay: float = 0.5, normalize: bool = True, mantissa: int = 6, silent: bool = False)

Returns the Graph Hopper kernel between two graphs. This kernel compares hop-wise shortest-path frontiers between nodes in two graphs using an automatically selected node-level kernel: numeric Radial Basis Function (RBF) if the key values are numeric, categorical (delta) if the key values are non-numeric, or vertex degree if key is None or missing. See Vishwanathan et al. (2010) for path-based graph kernels.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

keystr , optional

The vertex dictionary key used to derive node features. If numeric for most vertices, a numeric RBF node kernel is used; if non-numeric, a delta node kernel is used. If None or missing, the vertex degree is used as a numeric feature. Default is None.

maxHopsint , optional

The maximum shortest-path hop distance to consider. Default is 3.

decayfloat , optional

A per-hop geometric decay factor in the range (0, 1]. Default is 0.5.

normalizebool , optional

If True, the kernel is cosine-normalized using self-kernel values so that identical graphs score 1.0. The default is True.

mantissaint , optional

The number of decimal places to which to round the result. Default is 6.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
float

The (optionally normalized) Graph Hopper kernel value rounded to the specified mantissa.

static Impose(graphA, graphB, vertexKeys=None, useCentroid: bool = False, tolerance: float = 0.0001, silent: bool = False)

Imposes the second input graph on the first input graph based on the input vertex keys. See https://en.wikipedia.org/wiki/Boolean_operation.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

vertexKeyslist or str , optional

The vertex dictionary key (str) or keys (list of str) to use to determine if two vertices are the same. If the vertexKeys are set to None or “loc” or “coord” or “xyz” (case insensitive), the distance between the vertices (within the tolerance) will be used to determine sameness. Default is None.

useCentroidbool , optional

If set to True, the coordinates of identical vertices from each graph are averaged to located the new merged vertex of the resulting graph. Otherwise, the coordinates of the vertex of the second input graph are used. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

the resultant graph. Vertex and edge dictionaries are merged.

static Imprint(graphA, graphB, vertexKeys, useCentroid: bool = False, tolerance: float = 0.0001, silent: bool = False)

Imprints the second input graph on the first input graph based on the input vertex keys. See https://en.wikipedia.org/wiki/Boolean_operation.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

vertexKeyslist or str , optional

The vertex dictionary key (str) or keys (list of str) to use to determine if two vertices are the same. If the vertexKeys are set to None or “loc” or “coord” or “xyz” (case insensitive), the distance between the vertices (within the tolerance) will be used to determine sameness. Default is None.

useCentroidbool , optional

If set to True, the coordinates of identical vertices from each graph are averaged to located the new merged vertex of the resulting graph. Otherwise, the coordinates of the vertex of the first input graph are used. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

the resultant graph. Vertex and edge dictionaries are merged.

static IncomingEdges(graph, vertex, directed: bool = False, tolerance: float = 0.0001) list

Returns the incoming edges connected to a vertex. An edge is considered incoming if its end vertex is coincident with the input vertex.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

The input vertex.

directedbool , optional

If set to True, the graph is considered to be directed. Otherwise, it will be considered as an unidrected graph. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The list of incoming edges

static IncomingVertices(graph, vertex, directed: bool = False, tolerance: float = 0.0001) list

Returns the incoming vertices connected to a vertex. A vertex is considered incoming if it is an adjacent vertex to the input vertex and the the edge connecting it to the input vertex is an incoming edge.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

The input vertex.

directedbool , optional

If set to True, the graph is considered to be directed. Otherwise, it will be considered as an unidrected graph. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The list of incoming vertices

static InducedSubgraph(graph, vertices: list = None, strict: bool = False, silent: bool = False, tolerance: float = 0.0001)

Returns the subgraph whose edges are connected to the given vertices according to the strict rule. Isolated vertices are included as-is.

If strict is True, both endpoints of an edge must be in vertices. If strict is False, at least one endpoint must be in vertices.

Parameters
graphtopologicpy.Graph

The input graph.

verticeslist[topologicpy.Vertex]

The list of vertices to test membership against.

strictbool, optional

If set to True, require both endpoints to be in vertices. Otherwise, require at least one endpoint to be in vertices. Default is False.

silentbool, optional

Isilent : bool, optional If set to True, all errors and warnings are suppressed. Default is False

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list[topologic_core.Edge]

The list of matching edges from the original graph (not recreated).

static Integration(graph, weightKey: str = 'length', normalize: bool = False, nxCompatible: bool = True, key: str = 'integration', colorKey: str = 'in_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

This is an alias method for Graph.ClosenessCentrality. Returns the integration (closeness centrality) of the input graph. The order of the returned list matches the order of Graph.Vertices(graph). See: https://en.wikipedia.org/wiki/Closeness_centrality

Parameters
graphtopologic_core.Graph

The input graph.

weightKeystr , optional

If specified, this edge attribute will be used as the distance weight when computing shortest paths. If set to a name containing “Length” or “Distance”, it will be mapped to “length”. Note: Graph.NetworkXGraph automatically provides a “length” attribute on all edges.

normalizebool , optional

If True, the returned values are rescaled to [0, 1]. Otherwise raw values from NetworkX (optionally using the improved formula) are returned.

nxCompatiblebool , optional

If True, use NetworkX’s wf_improved scaling (Wasserman and Faust). For single-component graphs it matches the original formula.

keystr , optional

The dictionary key under which to store the closeness centrality score.

colorKeystr , optional

The dictionary key under which to store a color derived from the score.

colorScalestr , optional

Plotly color scale name (e.g., “viridis”, “plasma”).

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list[float]

Integration (closeness centrality) values for vertices in the same order as Graph.Vertices(graph).

static Intersect(graphA, graphB, vertexKeys, vertexColorKey='color', useCentroid: bool = False, tolerance: float = 0.0001, silent: bool = False)

Intersect the two input graphs based on the input vertex keys. See https://en.wikipedia.org/wiki/Boolean_operation.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

vertexKeyslist or str , optional

The vertex dictionary key (str) or keys (list of str) to use to determine if two vertices are the same. If the vertexKeys are set to None or “loc” or “coord” or “xyz” (case insensitive), the distance between the vertices (within the tolerance) will be used to determine sameness. Default is None.

useCentroidbool , optional

If set to True, the coordinates of identical vertices from each graph are averaged to located the new merged vertex of the resulting graph. Otherwise, the coordinates of the vertex of the first input graph are used. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

the resultant graph. Vertex and edge dictionaries are merged.

static IsBipartite(graph, tolerance=0.0001)

Returns True if the input graph is bipartite. Returns False otherwise. See https://en.wikipedia.org/wiki/Bipartite_graph.

Parameters
graphtopologic_core.Graph

The input graph.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
bool

True if the input graph is complete. False otherwise

static IsCompiledRoutingGraph(obj)

Returns True if the input object is a compiled routing graph. Returns False otherwise.

Parameters
objany

The input object.

Returns
bool

True if the input object is a compiled routing graph. False otherwise.

static IsComplete(graph)

Returns True if the input graph is complete. Returns False otherwise. See https://en.wikipedia.org/wiki/Complete_graph.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
bool

True if the input graph is complete. False otherwise

static IsConnected(graph, vertexA, vertexB, silent: bool = False)

Returns True if the two input vertices are directly connected by an edge. Returns False otherwise.

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
bool

True if the input vertices are connected by an edge. False otherwise.

static IsEmpty(graph, silent: bool = False)

Tests if the input graph is empty (Has no vertices).

Parameters
graphtopologic_core.Graph

The input graph.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
bool

True if the two input graphs are isomorphic. False otherwise

static IsErdoesGallai(graph, sequence)

Returns True if the input sequence satisfies the Erdős–Gallai theorem. Returns False otherwise. See https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Gallai_theorem.

Parameters
graphtopologic_core.Graph

The input graph.

sequencelist

The input sequence.

Returns
bool

True if the input sequence satisfies the Erdős–Gallai theorem. False otherwise.

static IsIsomorphic(graphA, graphB, maxIterations=10, silent=False)

Tests if the two input graphs are isomorphic according to the Weisfeiler Lehman graph isomorphism test. See https://en.wikipedia.org/wiki/Weisfeiler_Leman_graph_isomorphism_test

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

maxIterationsint , optional

This number limits the number of iterations to prevent the function from running indefinitely, particularly for very large or complex graphs.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
bool

True if the two input graphs are isomorphic. False otherwise

static IsTree(graph)

Returns True if the input graph has a hierarchical tree-like structure. Returns False otherwise.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
bool

True if the input graph has a hierarchical tree-like structure. False otherwise.

static IsolatedVertices(graph)

Returns the list of isolated vertices in the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
list

The list of isolated vertices.

static JSONData(graph, propertiesKey: str = 'properties', verticesKey: str = 'vertices', edgesKey: str = 'edges', vertexLabelKey: str = '', edgeLabelKey: str = '', sourceKey: str = 'source', targetKey: str = 'target', xKey: str = 'x', yKey: str = 'y', zKey: str = 'z', geometryKey: str = 'brep', mantissa: int = 6, tolerance: float = 0.0001)

Converts the input graph into JSON data.

Parameters
graphtopologic_core.Graph

The input graph.

propertiesKeystr , optional

The desired key name to call the graph properties. Default is “properties”.

verticesKeystr , optional

The desired key name to call vertices. Default is “vertices”.

edgesKeystr , optional

The desired key name to call edges. Default is “edges”.

vertexLabelKeystr , optional

If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number. Note: If vertex labels are not unique, they will be forced to be unique.

edgeLabelKeystr , optional

If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number. Note: If edge labels are not unique, they will be forced to be unique.

sourceKeystr , optional

The dictionary key used to store the source vertex. Default is “source”.

targetKeystr , optional

The dictionary key used to store the target vertex. Default is “target”.

xKeystr , optional

The desired key name to use for x-coordinates. Default is “x”.

yKeystr , optional

The desired key name to use for y-coordinates. Default is “y”.

zKeystr , optional

The desired key name to use for z-coordinates. Default is “z”.

geometryKeystr , optional

The desired key name to use for geometry. Default is “brep”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
dict

The JSON data

static JSONLDData(graph, context=None, verticesKey='nodes', edgesKey='edges', labelKey='label', sourceKey='source', targetKey='target', categoryKey='category', xKey='x', yKey='y', zKey='z', mantissa=6)

Exports the Graph to a JSON-LD representation.

Parameters
graphtopologic_core.Graph

The TopologicPy Graph object to export.

contextdict, optional

A JSON-LD context mapping TopologicPy keys to IRIs (e.g., schema.org, geo, etc.).

verticesKeystr , optional

The desired key name to call vertices. Default is “vertices”.

edgesKeystr , optional

The desired key name to call edges. Default is “edges”.

labelKeystr , optional

The desired key name to use for label. Default is “label”.

sourceKeystr , optional

The desired key name to use for source. Default is “source”.

targetKeystr , optional

The desired key name to use for target. Default is “target”.

categoryKeystr , optional

The desired key name to use for lcategoryabel. Default is “category”.

xKeystr , optional

The desired key name to use for x-coordinates. Default is “x”.

yKeystr , optional

The desired key name to use for y-coordinates. Default is “y”.

zKeystr , optional

The desired key name to use for z-coordinates. Default is “z”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
dict

A JSON-LD representation of the graph.

static JSONLDString(graph, context=None, verticesKey='nodes', edgesKey='edges', labelKey='label', sourceKey='source', targetKey='target', categoryKey='category', xKey='x', yKey='y', zKey='z', indent=2, sortKeys=False, mantissa=6)

Converts the input graph into a JSON-LD string.

Parameters
graphtopologic_core.Graph

The TopologicPy Graph object to export.

contextdict, optional

A JSON-LD context mapping TopologicPy keys to IRIs (e.g., schema.org, geo, etc.)

contextdict, optional

A JSON-LD context mapping TopologicPy keys to IRIs (e.g., schema.org, geo, etc.).

verticesKeystr , optional

The desired key name to call vertices. Default is “vertices”.

edgesKeystr , optional

The desired key name to call edges. Default is “edges”.

labelKeystr , optional

The desired key name to use for label. Default is “label”.

sourceKeystr , optional

The desired key name to use for source. Default is “source”.

targetKeystr , optional

The desired key name to use for target. Default is “target”.

categoryKeystr , optional

The desired key name to use for lcategoryabel. Default is “category”.

xKeystr , optional

The desired key name to use for x-coordinates. Default is “x”.

yKeystr , optional

The desired key name to use for y-coordinates. Default is “y”.

zKeystr , optional

The desired key name to use for z-coordinates. Default is “z”.

indentint , optional

The desired indent. Default is 2.

sortKeysbool , optional

If set to True, the keys will be sorted. Otherwise, they won’t be. Default is False.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
——-
dict

A JSON-LD representation of the graph.

static JSONString(graph, verticesKey='vertices', edgesKey='edges', vertexLabelKey='', edgeLabelKey='', xKey='x', yKey='y', zKey='z', indent=4, sortKeys=False, mantissa=6)

Converts the input graph into a JSON string.

Parameters
graphtopologic_core.Graph

The input graph.

verticesKeystr , optional

The desired key name to call vertices. Default is “vertices”.

edgesKeystr , optional

The desired key name to call edges. Default is “edges”.

vertexLabelKeystr , optional

If set to a valid string, the vertex label will be set to the value at this key. Otherwise it will be set to Vertex_XXXX where XXXX is a sequential unique number. Note: If vertex labels are not unique, they will be forced to be unique.

edgeLabelKeystr , optional

If set to a valid string, the edge label will be set to the value at this key. Otherwise it will be set to Edge_XXXX where XXXX is a sequential unique number. Note: If edge labels are not unique, they will be forced to be unique.

xKeystr , optional

The desired key name to use for x-coordinates. Default is “x”.

yKeystr , optional

The desired key name to use for y-coordinates. Default is “y”.

zKeystr , optional

The desired key name to use for z-coordinates. Default is “z”.

indentint , optional

The desired amount of indent spaces to use. Default is 4.

sortKeysbool , optional

If set to True, the keys will be sorted. Otherwise, they won’t be. Default is False.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
str

The JSON str

static KHopsSubgraph(graph, vertices: list, k: int = 1, direction: str = 'both', silent: bool = False)

Returns a subgraph consisting of the k-hop neighborhood around the input list of seed vertices.

Parameters
graphtopologicpy.Graph

The input graph.

verticeslist

The input list of seed vertices.

kint, optional

Number of hops. Default is 1.

directionstr, optional

‘both’, ‘out’, or ‘in’. Default ‘both’.

silentbool, optional

Suppress warnings/errors. Default False.

Returns
topologicpy.Graph or None

The resulting subgraph, or None on error.

static Kernel(graphA, graphB, method: str = 'WL', key: str = None, iterations: int = 2, maxHops: int = 3, decay: float = 0.5, normalize: bool = True, mantissa: int = 6, silent: bool = False, **kwargs)

Returns a graph-to-graph kernel value using the selected method. This is a convenience dispatcher over specific kernel implementations (e.g., WL and Hopper).

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

methodstr , optional

The kernel method to use. Supported values: “WL” (Weisfeiler–Lehman), “Hopper” (Graph Hopper). The default is “WL”.

keystr , optional

A vertex dictionary key used by the selected method to derive node labels/features. For “WL”, if None the vertex degree is used as the initial label. For “Hopper”, if None or missing, the vertex degree is used as a numeric feature. Default is None.

iterationsint , optional

WL-specific parameter: number of WL iterations. Ignored by other methods. Default is 2.

maxHopsint , optional

Hopper-specific parameter: maximum shortest-path hop distance. Ignored by other methods. Default is 3.

decayfloat , optional

Hopper-specific parameter: per-hop geometric decay in (0, 1]. Ignored by other methods. Default is 0.5.

normalizebool , optional

If True, returns a normalized kernel score in [0, 1] when supported by the method. Default is True.

mantissaint , optional

Number of decimal places for rounding the returned value. Default is 6.

silentbool , optional

If True, error and warning messages are suppressed. Default is False.

**kwargs

Reserved for future method-specific options; ignored by current implementations.

Returns
float

The kernel value computed by the selected method, rounded to mantissa, or None if inputs are invalid or the method is unsupported.

Notes

  • “WL” calls Graph.WLKernel(graphA, graphB, key=…, iterations=…, normalize=…, mantissa=…).

  • “Hopper” calls Graph.HopperKernel(graphA, graphB, key=…, maxHops=…, decay=…, normalize=…, mantissa=…).

  • Method selection is case-insensitive and tolerates common aliases for WL.

static Laplacian(graph, silent: bool = False, normalized: bool = False)

Returns the Laplacian matrix of the input graph. See https://en.wikipedia.org/wiki/Laplacian_matrix.

Parameters
graphtopologic_core.Graph

The input graph.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

normalizedbool , optional

If set to True, the returned Laplacian matrix is normalized. Default is False.

Returns
list

The Laplacian matrix as a nested list.

static Leaves(graph, weightKey: str = None, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Returns a list of all vertices that have a degree of 1, also called leaf nodes.

Parameters
graphtopologic_core.Graph

The input graph.

weightKeystr , optional

If specified, the value in the connected edges’ dictionary specified by the weightKey string will be aggregated to calculate the vertex degree. If a numeric value cannot be retrieved from an edge, a value of 1 is used instead. This is used in weighted graphs. if weightKey is set to “Length” or “Distance”, the length of the edge will be used as its weight.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The list of leaf nodes

static LineGraph(graph, transferVertexDictionaries: bool = False, transferEdgeDictionaries: bool = False, ontology: bool = True, tolerance=0.0001, silent=False)

Returns the line graph of the input graph. In the resulting graph, each edge in the original graph becomes a vertex, and adjacency between edges becomes an edge. If ontology is set to True, ontology annotations are added.

Parameters
graphtopologic_core.Graph

The input graph.

transferVertexDictionariesbool , optional

If set to True, vertex dictionaries from the input graph are transferred to the corresponding vertices in the resulting graph. Default is False.

transferEdgeDictionariesbool , optional

If set to True, edge dictionaries from the input graph are transferred to the corresponding edges in the resulting graph. Default is False.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The resulting line graph.

static LocalClusteringCoefficient(graph, vertices: list = None, key: str = 'lcc', mantissa: int = 6, tolerance: float = 0.0001)

Returns the local clustering coefficient of the input list of vertices within the input graph. See https://en.wikipedia.org/wiki/Clustering_coefficient.

Parameters
graphtopologic_core.Graph

The input graph.

verticeslist , optional

The input list of vertices. If set to None, the local clustering coefficient of all vertices will be computed. Default is None.

keystr , optional

The dictionary key under which to store the local clustering coefficient score. Default is “lcc”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The list of local clustering coefficient. The order of the list matches the order of the list of input vertices.

static LongestPath(graph, vertexA, vertexB, vertexKey=None, edgeKey=None, costKey=None, timeLimit=10, tolerance=0.0001)

Returns the longest path that connects the input vertices.

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex.

vertexKeystr , optional

The vertex key to maximize. If set the vertices dictionaries will be searched for this key and the associated value will be used to compute the longest path that maximizes the total value. The value must be numeric. Default is None.

edgeKeystr , optional

The edge key to maximize. If set the edges dictionaries will be searched for this key and the associated value will be used to compute the longest path that maximizes the total value. The value of the key must be numeric. If set to “length” (case insensitive), the shortest path by length is computed. Default is “length”.

costKeystr , optional

If not None, the total cost of the longest_path will be stored in its dictionary under this key. Default is None.

timeLimitint , optional

The time limit in second. Default is 10 seconds.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Wire

The longest path between the input vertices.

Match(graphB, vertexKeys: list = None, edgeKeys: list = None, maxMatches: int = 10, timeLimit: int = 10, tolerance: float = 0.0, silent: bool = False)

Matches graphA as a subgraph of graphB using structural and semantic similarity.

Parameters
graphAtopologic_core.Graph

The smaller graph (subgraph).

graphBtopologic_core.Graph

The larger graph (supergraph).

vertexKeysstr or list of str, optional

Keys used to semantically compare vertices.

edgeKeysstr or list of str, optional

Keys used to semantically compare edges.

maxMatchesint , optional

The maximum number of matches to find. Default is 10.

timeLimitint , optional

The time limit in seconds. Default is 10 seconds. Note that this time limit only applies to finding the matches.

tolerancefloat, optional

Allowed numeric deviation or minimum string similarity (e.g. 0.2 = ≥80% match). Default is 0.

silentbool, optional

If True, suppresses warnings and errors.

Returns
list of dict

List of mappings from node index in graphA to graphB, sorted by descending similarity.

static MaximumDelta(graph)

Returns the maximum delta of the input graph. The maximum delta of a graph is the maximum degree of a vertex in the graph.

Parameters
graphtopologic_core.Graph

the input graph.

Returns
int

The maximum delta.

static MaximumFlow(graph, source, sink, edgeKeyFwd=None, edgeKeyBwd=None, bidirKey=None, bidirectional=False, residualKey='residual', tolerance=0.0001)

Returns the maximum flow of the input graph. See https://en.wikipedia.org/wiki/Maximum_flow_problem

Parameters
graphtopologic_core.Graph

The input graph. This is assumed to be a directed graph

sourcetopologic_core.Vertex

The input source vertex.

sinktopologic_core.Vertex

The input sink/target vertex.

edgeKeyFwdstr , optional

The edge dictionary key to use to find the value of the forward capacity of the edge. If not set, the length of the edge is used as its capacity. Default is None.

edgeKeyBwdstr , optional

The edge dictionary key to use to find the value of the backward capacity of the edge. This is only considered if the edge is set to be bidrectional. Default is None.

bidirKeystr , optional

The edge dictionary key to use to determine if the edge is bidrectional. Default is None.

bidrectionalbool , optional

If set to True, the whole graph is considered to be bidirectional. Default is False.

residualKeystr , optional

The name of the key to use to store the residual value of each edge capacity in the input graph. Default is “residual”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
float

The maximum flow.

static Merge(graphA, graphB, vertexKeys=None, vertexColorKey='color', useCentroid: bool = False, tolerance: float = 0.0001, silent: bool = False)

Merges the two input graphs based on the input vertex keys. This is an alias for Graph.Union. See https://en.wikipedia.org/wiki/Boolean_operation.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

vertexKeyslist or str , optional

The vertex dictionary key (str) or keys (list of str) to use to determine if two vertices are the same. If the vertexKeys are set to None or “loc” or “coord” or “xyz” (case insensitive), the distance between the vertices (within the tolerance) will be used to determine sameness. Default is None.

vertexColorKeystr , optional

The dictionary key that is storing the vertex’s color. The final colors will be averaged. Default is “color”.

useCentroidbool , optional

If set to True, the coordinates of identical vertices from each graph are averaged to located the new merged vertex of the resulting graph. Otherwise, the coordinates of the vertex of the first input graph are used. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

the resultant graph. Vertex and edge dictionaries are merged.

static MergeVertices(graph, *vertices, targetVertex=None, transferDictionaries: bool = True, tolerance: float = 0.0001, silent: bool = False)

Merges the input vertices into one vertex and reconnects all edges to the new vertex. If two of the input vertices are the end points of the same edge, that edge is deleted.

Parameters
graphtopologic_core.Graph

The input graph.

*verticestopologic_core.Vertex

Two or more instances of topologic_core.Topology to be processed.

targetVertextopologic_core.Vertex, optional

The target vertex to merge into. If None, a centroid is computed. Default is None.

transferDictionariesbool, optional

If True, the dictionaries of all input vertices (including the target vertex if given) are merged. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

A new graph with the vertices merged and edges updated.

static MeshData(graph, mantissa: int = 6, tolerance: float = 0.0001)

Returns the mesh data of the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
dict

The python dictionary of the mesh data of the input graph. The keys in the dictionary are: ‘vertices’ : The list of [x, y, z] coordinates of the vertices. ‘edges’ : the list of [i, j] indices into the vertices list to signify and edge that connects vertices[i] to vertices[j]. ‘vertexDictionaries’ : The python dictionaries of the vertices (in the same order as the list of vertices). ‘edgeDictionaries’ : The python dictionaries of the edges (in the same order as the list of edges).

static MetricDistance(graph, vertexA, vertexB, mantissa: int = 6, tolerance: float = 0.0001)

Returns the shortest-path distance between the input vertices. See https://en.wikipedia.org/wiki/Distance_(graph_theory).

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
float

The shortest-path metric distance between the input vertices.

static MinimumDelta(graph)

Returns the minimum delta of the input graph. The minimum delta of a graph is the minimum degree of a vertex in the graph.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
int

The minimum delta.

static MinimumSpanningTree(graph, edgeKey=None, ontology: bool = True, tolerance=0.0001)

Returns the minimum spanning tree of the input graph. See https://en.wikipedia.org/wiki/Minimum_spanning_tree.

This implementation uses Kruskal’s algorithm with a disjoint-set union structure. It avoids repeated Graph.Path and Graph.NearestVertex calls.

The returned vertices are assigned an “index” key, and the returned edges are assigned “src” and “dst” keys corresponding to those vertex indices.

Parameters
graphtopologic_core.Graph

The input graph.

edgeKeystr , optional

If set, the value of the edgeKey will be used as the edge weight. The value associated with edgeKey must be numerical. If not set, edge length is used. Default is None.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Graph

The minimum spanning tree.

static NavigationGraph(face, sources=None, destinations=None, numWorkers=None, ontology: bool = True, tolerance=0.0001)

Creates a 2D navigation graph.

Parameters
facetopologic_core.Face

The input boundary. View edges will be clipped to this face. The holes in the face are used as the obstacles

sourceslist

The first input list of sources (vertices). Navigation edges will connect these veritces to destinations.

destinationslist

The input list of destinations (vertices). Navigation edges will connect these vertices to sources.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

numWorkersint, optional

Number of workers run in parallel to process. Default is None which sets the number to twice the number of CPU cores.

Returns
topologic_core.Graph

The navigation graph.

static NearestVertex(graph, vertex)

Returns the vertex in the input graph that is the nearest to the input vertex.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

The input vertex.

Returns
topologic_core.Vertex

The vertex in the input graph that is the nearest to the input vertex.

static Neigborhood(graph, vertices: list = None, k: int = 1, searchType: str = 'equal to', key: str = None, value: Any = None, direction: str = 'both', silent: bool = False)

Returns a subgraph consisting of the k-hop neighborhood around the input list of seed vertices.

Parameters
graphtopologicpy.Graph

The input graph.

verticeslist

The input list of seed vertices. If set to None, all the vertices of the graph will be searched.

kint, optional

Number of hops. Default is 1.

searchTypestr , optional

The type of search query to conduct in the topology’s dictionary to filter the input vertices. This can be one of “any”, “equal to”, “contains”, “starts with”, “ends with”, “not equal to”, “does not contain”. Default is “equal to”.

keystr , optional

The dictionary key to search within. If set, the input vertices will be filtered based on this key and value pair. Default is None which means it will not filter the input vertices.

valuestr , optional

The value to search for at the specified key. If set, the input vertices will be filtered based on this value. Default is None which means it will not filter the input vertices..

directionstr, optional

‘both’, ‘out’, or ‘in’. Default ‘both’.

silentbool, optional

Suppress warnings/errors. Default False.

Returns
topologicpy.Graph or None

The resulting subgraph, or None on error.

static NetworkXGraph(graph, xKey='x', yKey='y', zKey='z', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Converts the input graph into a NetworkX Graph. See http://networkx.org

Parameters
graphtopologic_core.Graph

The input graph.

xKeystr , optional

The dictionary key under which to store the X-Coordinate of the vertex. Default is ‘x’.

yKeystr , optional

The dictionary key under which to store the Y-Coordinate of the vertex. Default is ‘y’.

zKeystr , optional

The dictionary key under which to store the Z-Coordinate of the vertex. Default is ‘z’.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
networkX Graph

The created networkX Graph

static Order(graph)

Returns the graph order of the input graph. The graph order is its number of vertices.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
int

The number of vertices in the input graph

static OutgoingEdges(graph, vertex, directed: bool = False, tolerance: float = 0.0001) list

Returns the outgoing edges connected to a vertex. An edge is considered outgoing if its start vertex is coincident with the input vertex.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

The input vertex.

directedbool , optional

If set to True, the graph is considered to be directed. Otherwise, it will be considered as an unidrected graph. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The list of outgoing edges

static OutgoingVertices(graph, vertex, directed: bool = False, tolerance: float = 0.0001) list

Returns the list of outgoing vertices connected to a vertex. A vertex is considered outgoing if it is an adjacent vertex to the input vertex and the the edge connecting it to the input vertex is an outgoing edge.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

The input vertex.

directedbool , optional

If set to True, the graph is considered to be directed. Otherwise, it will be considered as an unidrected graph. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The list of incoming vertices

static PageRank(graph, alpha: float = 0.85, maxIterations: int = 100, normalize: bool = True, directed: bool = False, key: str = 'page_rank', colorKey: str = 'pr_color', colorScale: str = 'viridis', mantissa: int = 6, tolerance: float = 0.0001)

PageRank with stable vertex mapping (by coordinates) so neighbors resolve correctly. Handles dangling nodes; uses cached neighbor lists and L1 convergence.

static Partition(graph, method: str = 'Betweenness', n: int = 2, m: int = 10, key: str = 'partition', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Partitions the input graph based on the desired partition method. See https://en.wikipedia.org/wiki/Graph_partition.

Parameters
graphtopologicp.Graph

The input topologic graph.

methodstr , optional

The desired partitioning method. The options are: - “Betweenness” - “Community” or “Louvain” - “Fiedler” or “Eigen” It is case insensitive. Default is “Betweenness”

nint , optional

The desired number of partitions when selecting the “Betweenness” method. This parameter is ignored for other methods. Default is 2.

mint , optional

The desired maximum number of tries to partition the graph when selecting the “Betweenness” method. This parameter is ignored for other methods. Default is 10.

keystr , optional

The vertex and edge dictionary key under which to store the parition number. Default is “partition”. Valid partition numbers start from 1. Cut edges receive a partition number of 0.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologicpy.Graph

The partitioned topologic graph.

static Path(graph, vertexA, vertexB, tolerance=0.0001)

Returns a path (wire) in the input graph that connects the input vertices.

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex.

tolerancefloat, optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Wire

The path (wire) in the input graph that connects the input vertices.

static PropagateValues(graph, sourceVertexKey: str = 'id', targetVertexKey: str = 'id', edgeKey: str = 'predicate', predicates: list = None, sourceKeys: list = None, targetKeys: list = None, direction: str = 'out', overwrite: bool = False, prefix: str = '', suffix: str = '', tolerance: float = 0.0001, silent: bool = False)

Propagates dictionary values from source vertices to target vertices along selected graph edges.

This is useful for workflows such as propagating properties from IFC type nodes to instance nodes through IfcRelDefinesByType relationships, or propagating classifications/materials through semantic graph relations.

Parameters
graphtopologic_core.Graph

The input graph.

sourceVertexKeystr , optional

Vertex dictionary key used to identify source vertices. Default is “id”.

targetVertexKeystr , optional

Vertex dictionary key used to identify target vertices. Default is “id”.

edgeKeystr , optional

Edge dictionary key used to identify the relationship/predicate. Default is “predicate”.

predicateslist , optional

If provided, values are propagated only along edges whose predicate is in this list. Matching is case-insensitive. Default is None.

sourceKeyslist , optional

Dictionary keys to copy from source vertices. If None, all source dictionary keys except index/key/id metadata are considered. Default is None.

targetKeyslist , optional

Dictionary keys to write to target vertices. If None, sourceKeys are used with optional prefix/suffix. Default is None.

directionstr , optional

Direction of propagation. Options are: - “out”: from edge start vertex to edge end vertex - “in”: from edge end vertex to edge start vertex - “both”: propagate in both directions Default is “out”.

overwritebool , optional

If True, existing target values are overwritten. If False, only empty or missing target values are written. Default is False.

prefixstr , optional

Prefix added to target keys when targetKeys is None. Default is “”.

suffixstr , optional

Suffix added to target keys when targetKeys is None. Default is “”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If True, suppresses error and warning messages. Default is False.

Returns
topologic_core.Graph

The input graph with propagated values written into vertex dictionaries.

static PyvisGraph(graph, path, overwrite: bool = True, height: int = 900, backgroundColor: str = 'white', fontColor: str = 'black', notebook: bool = False, vertexSize: int = 6, vertexSizeKey: str = None, vertexColor: str = 'black', vertexColorKey: str = None, vertexLabel: str = '', vertexLabelKey: str = None, vertexGroupKey: str = None, vertexGroups: list = None, minVertexGroup: float = None, maxVertexGroup: float = None, edgeLabel: str = '', edgeLabelKey: str = None, edgeWeight: int = 0, edgeWeightKey: str = None, edgeColor: str = 'black', edgeColorKey: str = None, showNeighbours: bool = True, selectMenu: bool = True, filterMenu: bool = True, colorScale: str = 'viridis', tolerance: float = 0.0001)

Displays a pyvis graph. See https://pyvis.readthedocs.io/.

Parameters
graphtopologic_core.Graph

The input graph.

pathstr

The desired file path to the HTML file into which to save the pyvis graph.

overwritebool , optional

If set to True, the HTML file is overwritten.

heightint , optional

The desired figure height in pixels. Default is 900 pixels.

backgroundColorstr, optional

The desired background color for the figure. This can be a named color or a hexadecimal value. Default is ‘white’.

fontColorstr , optional

The desired font color for the figure. This can be a named color or a hexadecimal value. Default is ‘black’.

notebookbool , optional

If set to True, the figure will be targeted at a Jupyter Notebook. Note that this is not working well. Pyvis has bugs. Default is False.

vertexSizeint , optional

The desired default vertex size. Default is 6.

vertexSizeKeystr , optional

If not set to None, the vertex size will be derived from the dictionary value set at this key. If set to “degree” or “neighbours” or “neighbors”, the size of the vertex will be determined by its degree. Default is None.

vertexColorstr , optional

The desired default vertex color. This can be a named color or a hexadecimal value. Default is ‘black’.

vertexColorKeystr , optional

If not set to None, the vertex color will be derived from the dictionary value set at this key. Default is None.

vertexLabelstr , optional

The default vertex label. Default is “”.

vertexLabelKeystr , optional

If not set to None, the vertex label will be derived from the dictionary value set at this key. Default is None.

vertexGroupKeystr , optional

If not set to None, the vertex color will be determined by the group the vertex belongs to as derived from the value set at this key. Default is None.

vertexGroupslist , optional

The list of all possible vertex groups. This will help in vertex coloring. Default is None.

minVertexGroupint or float , optional

If the vertex groups are numeric, specify the minimum value you wish to consider for vertex coloring. Default is None.

maxVertexGroupint or float , optional

If the vertex groups are numeric, specify the maximum value you wish to consider for vertex coloring. Default is None.

edgeLabelstr , optional

The default edge label. Default is “”.

edgeLabelKeystr , optional

If not set to None, the edge label will be derived from the dictionary value set at this key. Default is None.

edgeWeightint , optional

The desired default weight of the edge. This determines its thickness. Default is 0.

edgeWeightKeystr, optional

If not set to None, the edge weight will be derived from the dictionary value set at this key. If set to “length” or “distance”, the weight of the edge will be determined by its geometric length. Default is None.

edgeColorstring , optional

The desired default color of the edge. Default is “black”.

edgeColorKeystr, optional

If not set to None, the edge color will be derived from the dictionary value set at this key. Default is None.

showNeighboursbool , optional

If set to True, a list of neighbors is shown when you hover over a vertex. Default is True.

selectMenubool , optional

If set to True, a selection menu will be displayed. Default is True

filterMenubool , optional

If set to True, a filtering menu will be displayed. Default is True.

colorScalestr , optional

The desired type of plotly color scales to use (e.g. “viridis”, “plasma”). Default is “viridis”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
None

The pyvis graph is displayed either inline (notebook mode) or in a new browser window or tab.

static Quotient(topology, topologyType: str = 'vertex', key: str = None, groupLabelKey: str = None, groupCountKey: str = 'count', weighted: bool = False, edgeWeightKey: str = 'weight', idKey: str = None, transferDictionaries=False, silent: bool = False)

Construct the quotient graph induced by grouping sub-topologies (Cells/Faces/Edges/Vertices) by a dictionary value. Two groups are connected if any member of one is adjacent to any member of the other via Topology.AdjacentTopologies. If weighted=True, edge weights count the number of distinct member-level adjacencies across groups. See https://en.wikipedia.org/wiki/Quotient_graph

Parameters
topology: topologic_core.Topology or topologic_core.Graph

The input topology or graph.

topologyType: str , optional

The type of subtopology for which to search. This can be one of “vertex”, “edge”, “face”, “cell”. It is case-insensitive. Default is “Vertex”.

key: str , optional

Dictionary key used to form groups. If None, all items fall into one group.

groupLabelKey: str , optional

Vertex-dictionary key storing the group label. Default is None which uses the key input parameter.

groupCountKey: str , optional

Vertex-dictionary key storing the group size. Default is “count”.

weighted: bool , optional

If True, store counts of cross-group adjacencies on edges under edgeWeightKey. Default is False.

edgeWeightKeystr , optional

Edge-dictionary key storing the weight when weighted=True. Default “weight”.

idKey: str , optional

Optional dictionary key that uniquely identifies each sub-topology. If provided and present on both members, lookup is O(1) without calling Topology.IsSame. If missing, falls back to Topology.IsSame. Default is None.

transferDictionaries: bool , optional

If set to True, the dictionaries of the members of the group are transfered and merged into the representative vertex. Default is False.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph
static RDFString(graph, subjectKey: str = 'id', predicateKey: str = 'predicate', objectKey: str = 'id', baseIRI: str = 'https://topologic.app/resource/', ontologyIRI: str = 'http://w3id.org/topologicpy#', includeMetadata: bool = True, format: str = 'turtle', tolerance: float = 0.0001, silent: bool = False)

Returns an RDF/Turtle string representation of a TopologicPy Graph.

Parameters
graphtopologic_core.Graph

The input graph.

subjectKeystr , optional

Vertex dictionary key used to identify RDF subjects. Default is “id”.

predicateKeystr , optional

Edge dictionary key used to identify RDF predicates. Default is “predicate”.

objectKeystr , optional

Vertex dictionary key used to identify RDF objects. Default is “id”.

baseIRIstr , optional

Base IRI for generated resources. Default is “https://topologic.app/resource/”.

ontologyIRIstr , optional

Base IRI for generated predicates/classes. Default is “http://w3id.org/topologicpy#”.

includeMetadatabool , optional

If True, vertex labels, types, and selected dictionary values are exported. Default is True.

formatstr , optional

Currently only “turtle” is supported. Default is “turtle”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If True, suppresses error and warning messages. Default is False.

Returns
str

RDF/Turtle representation of the input graph.

static RemoveEdge(graph, *edges, tolerance=0.0001, silent: bool = False)

Removes the input edge from the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

edgestopologic_core.Edge or list of edges

The input edge.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with the input edge removed.

static RemoveIsolatedEdges(graph, removeVertices: bool = True, tolerance: float = 0.0001, silent: bool = False)

Removes all isolated edges from the input graph. Isolated edges are those whose vertices are not connected to any other edges. That is, they have a degree of 1.

Parameters
graphtopologic_core.Graph

The input graph.

removeVerticesbool , optional

If set to True, the end vertices of the edges are also removed. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with all isolated vertices removed.

static RemoveIsolatedVertices(graph, silent: bool = True)

Removes all isolated vertices from the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The input graph with all isolated vertices removed.

static RemoveVertex(graph, vertex, silent: bool = False)

Removes the input vertex from the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex or list of vertices

The input vertex or list of vertices.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Graph

The input graph with the input vertex removed.

static Reshape(graph, shape='spring 2D', k=0.8, seed=None, iterations=50, rootVertex=None, size=1, factor=1, sides=16, key='', tolerance=0.0001, silent=False)

Reshapes the input graph according to the desired input shape parameter.

Parameters
graphtopologic_core.Graph

The input graph.

shapestr , optional

The desired shape of the graph. [‘circle 2D’, ‘grid 2D’, ‘line 2D’, ‘radial 2D’, ‘spring 2D’, ‘tree 2D’, ‘grid 3D’, ‘sphere 3D’, ‘tree 3D’] If set to ‘spring 2D’ or ‘spring_3d’, the algorithm uses a simplified version of the Fruchterman-Reingold force-directed algorithm to distribute the vertices. If set to ‘radial 2D’, the nodes will be distributed along concentric circles in the XY plane. If set to ‘tree 2D’ or ‘tree 3D’, the nodes will be distributed using the Reingold-Tillford layout. If set to ‘circle 2D’, the nodes will be distributed on the cirumference of a segemented circles in the XY plane, based on the size and sides input parameter (radius=size/2). If set to ‘line 2D’, the nodes will be distributed on a line in the XY plane based on the size input parameter (length=size). If set to ‘spehere 3D’, the nodes will be distributed on the surface of a sphere based on the size input parameter raidus=size/2). If set to ‘grid 2D’, the nodes will be distributed on a grid in the XY plane with size based on the size input parameter (length=width=size). If set to ‘grid 3D’, the nodes will be distributed on a 3D cubic grid/matrix based on the size input parameter(width=length=height=size). If set to ‘cluster 2D’, or ‘cluster 3D, the nodes will be clustered according to the ‘key’ input parameter. The overall radius of the cluster is determined by the size input parameter (radius = size/2) The default is ‘spring 2D’.

kfloat, optional

The desired spring constant to use for the attractive and repulsive forces. Default is 0.8.

seedint , optional

The desired random seed to use. Default is None.

iterationsint , optional

The desired maximum number of iterations to solve the forces in the ‘spring’ mode. Default is 50.

rootVertextopologic_core.Vertex , optional

The desired vertex to use as the root of the tree and radial layouts.

sizefloat , optional

The desired overall size of the graph.

sidesint , optional

The desired number of sides of the circle layout option. Default is 16

lengthfloat, optional

The desired horizontal length for the line layout option. Default is 1.0.

keystring, optional

The key under which to find the clustering value for the ‘cluster_2d’ and ‘cluster_3d’ options. Default is “”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The reshaped graph.

static SetDictionary(graph, dictionary)

Sets the input graph’s dictionary to the input dictionary

Parameters
graphtopologic_core.Graph

The input graph.

dictionarytopologic_core.Dictionary or dict

The input dictionary.

Returns
topologic_core.Graph

The input graph with the input dictionary set in it.

static ShortestPath(graph, vertexA, vertexB, vertexKey: str = '', edgeKey: str = 'Length', turnWeight: float = 0.0, turnPower: float = 1.0, turnKey: str = '', directed: bool = False, edgeFilter: callable = None, vertexFilter: callable = None, edgeCostFunc: callable = None, vertexCostFunc: callable = None, turnCostFunc: callable = None, useAStar: bool = False, heuristicScale: float = 1.0, returnVertices: bool = False, returnEdges: bool = False, tolerance: float = 0.0001, silent: bool = False)

Returns the shortest path (as a Wire) between two vertices in a Graph using a pure-Python, feature-rich routing algorithm.

The path cost is computed as a weighted sum of: - edge traversal cost (edgeKey or geometric length), - optional vertex visitation cost (vertexKey), - optional turn/transition cost between consecutive edges (Spread-based).

This method is backward compatible with the original TopologicPy API, but extends it with advanced routing features such as turn penalties, custom filters, and A* search, all without relying on the C++ core.

Parameters
graphtopologic_core.Graph

The input graph on which routing is performed.

vertexAtopologic_core.Vertex

The start vertex. It is snapped to the nearest vertex in the graph.

vertexBtopologic_core.Vertex

The end vertex. It is snapped to the nearest vertex in the graph.

vertexKeystr, optional

Name of a numeric key in each vertex dictionary whose value is added to the path cost when that vertex is entered. Higher values make routes avoid those vertices. If empty, no vertex cost is applied.

edgeKeystr, optional

Name of a numeric key in each edge dictionary used as the edge traversal cost. If set to “Length” (case-insensitive), geometric edge length is used. This is the primary contributor to path length.

transferDictionariesbool, optional

If True, dictionaries from the graph vertices are copied onto the vertices of the returned path. This does not affect routing, only the output data.

turnWeightfloat, optional

Controls how strongly turning is penalised relative to edge length. A value of 0 disables turn cost. Larger values favour straighter routes even if they are longer. Default is 1.

turnPowerfloat, optional

Controls how sharply turn penalties increase with turn severity. Values greater than 1 strongly penalise right-angle turns while allowing gentle bends. Default is 2.

turnKeystr, optional

Name of a numeric key in vertex dictionaries that scales turn cost locally. Useful for modelling junction complexity or restricted turning areas. Default is None.

directedbool, optional

If True, edges are traversed only from start to end vertex. If False, the graph is treated as undirected. Default is False.

edgeFiltercallable(edge) -> bool, optional

A function that returns False for edges that must not be traversed. This enforces hard constraints such as blocked corridors. Default is None.

vertexFiltercallable(vertex) -> bool, optional

A function that returns False for vertices that must not be visited (except for start and end vertices). Default is None.

edgeCostFunccallable(edge) -> float, optional

Custom function overriding edgeKey and geometric length to compute edge traversal cost.

vertexCostFunccallable(vertex) -> float, optional

Custom function overriding vertexKey to compute vertex visitation cost.

turnCostFunccallable(prev, curr, next, inEdge, outEdge, spread) -> float, optional

Fully custom function to compute turn cost between consecutive edges. Overrides turnWeight, turnPower, and turnKey.

useAStarbool, optional

If True, uses A* search instead of Dijkstra when edge costs are geometric, improving performance on large graphs.

heuristicScalefloat, optional

Multiplier for the A* heuristic (must be ≤ 1 for admissibility). Lower values make the search more conservative.

returnVerticesbool, optional

If True, returns both the Wire and the ordered list of vertices forming the path. Useful for debugging or analysis.

returnEdgesbool, optional

If True, returns both the Wire and the ordered list of edges forming the path. Useful for debugging or analysis.

tolerancefloat, optional

The desired tolerance. Default is 0.0001.

silentbool, optional

If True, suppresses error and warning messages. Default is False.

Returns
topologic_core.Wire

A wire representing the shortest path between the two input vertices, optionally straightened and with transferred dictionaries.

If returnVertices and/or returnEdges are True:
  • returnVertices=True -> returns (wire, path_vertex_indices)

  • returnEdges=True -> returns (wire, path_edge_index_pairs)

  • both True -> returns (wire, path_vertex_indices, path_edge_index_pairs)

static ShortestPathViaVertices(graph, vertexA, vertexB, vertexKey: str = '', viaKey: str = None, viaValues: list = None, edgeKey: str = 'Length', turnWeight: float = 0.0, turnPower: float = 1.0, turnKey: str = '', directed: bool = False, edgeFilter: callable = None, vertexFilter: callable = None, edgeCostFunc: callable = None, vertexCostFunc: callable = None, turnCostFunc: callable = None, useAStar: bool = False, heuristicScale: float = 1.0, returnVertices: bool = False, returnEdges: bool = False, tolerance: float = 0.0001, silent: bool = False)

Returns a head-to-tail path from start_vertex to end_vertex that passes through, in order, vertices whose dictionary value at key matches each value in via_values.

The function strings together shortest paths:

start_vertex -> via_1 -> via_2 -> … -> via_n -> end_vertex

If any via vertex cannot be found, any shortest path does not exist, returns None.

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The start vertex. It is snapped to the nearest vertex in the graph.

vertexBtopologic_core.Vertex

The end vertex. It is snapped to the nearest vertex in the graph.

vertexKeystr, optional

Name of a numeric key in each vertex dictionary whose value is added to the path cost when that vertex is entered. Higher values make routes avoid those vertices. If empty, no vertex cost is applied.

viaKeystr , optional

The vertex dictionary key used to identify the via vertices. Default is None.

viaValueslist

The ordered list of dictionary values that must be visited. Default is None.

vertexKeystr, optional

Name of a key in each vertex dictionary whose numeric value is added to the path cost when that vertex is entered. Higher values make routes avoid those vertices. If empty, no vertex cost is applied.

edgeKeystr, optional

Name of a numeric key in each edge dictionary used as the edge traversal cost. If set to “Length” (case-insensitive), geometric edge length is used. This is the primary contributor to path length.

transferDictionariesbool, optional

If True, dictionaries from the graph vertices are copied onto the vertices of the returned path. This does not affect routing, only the output data.

turnWeightfloat, optional

Controls how strongly turning is penalised relative to edge length. A value of 0 disables turn cost. Larger values favour straighter routes even if they are longer. Default is 1.

turnPowerfloat, optional

Controls how sharply turn penalties increase with turn severity. Values greater than 1 strongly penalise right-angle turns while allowing gentle bends. Default is 2.

turnKeystr, optional

Name of a numeric key in vertex dictionaries that scales turn cost locally. Useful for modelling junction complexity or restricted turning areas. Default is None.

directedbool, optional

If True, edges are traversed only from start to end vertex. If False, the graph is treated as undirected. Default is False.

edgeFiltercallable(edge) -> bool, optional

A function that returns False for edges that must not be traversed. This enforces hard constraints such as blocked corridors. Default is None.

vertexFiltercallable(vertex) -> bool, optional

A function that returns False for vertices that must not be visited (except for start and end vertices). Default is None.

edgeCostFunccallable(edge) -> float, optional

Custom function overriding edgeKey and geometric length to compute edge traversal cost.

vertexCostFunccallable(vertex) -> float, optional

Custom function overriding vertexKey to compute vertex visitation cost.

turnCostFunccallable(prev, curr, next, inEdge, outEdge, spread) -> float, optional

Fully custom function to compute turn cost between consecutive edges. Overrides turnWeight, turnPower, and turnKey.

useAStarbool, optional

If True, uses A* search instead of Dijkstra when edge costs are geometric, improving performance on large graphs.

heuristicScalefloat, optional

Multiplier for the A* heuristic (must be <= 1 for admissibility). Lower values make the search more conservative.

returnVerticesbool, optional

If True, returns both the Wire and the ordered list of vertex indices forming the path. Useful for debugging or analysis.

returnEdgesbool, optional

If True, returns both the Wire and the ordered list of edge indices forming the path. Useful for debugging or analysis.

tolerancefloat, optional

The desired tolerance. Default is 0.0001.

silentbool, optional

If True, suppresses error and warning messages. Default is False.

Returns
topologic_core.Wire

A wire representing the shortest path between the two input vertices, that passes through the vertices specified by their dictionary key and values.

If returnVertices and/or returnEdges are True:
  • returnVertices=True -> returns (wire, path_vertex_indices)

  • returnEdges=True -> returns (wire, path_edge_indices)

  • both True -> returns (wire, path_vertex_indices, path_edge_indices)

static ShortestPaths(graph, vertexA, vertexB, vertexKey='', edgeKey='length', timeLimit=10, pathLimit=10, tolerance=0.0001)

Returns the shortest path that connects the input vertices.

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex.

vertexKeystring , optional

The vertex key to minimise. If set the vertices dictionaries will be searched for this key and the associated value will be used to compute the shortest path that minimized the total value. The value must be numeric. Default is None.

edgeKeystring , optional

The edge key to minimise. If set the edges dictionaries will be searched for this key and the associated value will be used to compute the shortest path that minimized the total value. The value of the key must be numeric. If set to “length” (case insensitive), the shortest path by length is computed. Default is “length”.

timeLimitint , optional

The search time limit in seconds. Default is 10 seconds

pathLimit: int , optional

The number of found paths limit. Default is 10 paths.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

The list of shortest paths between the input vertices.

static Show(*graphs, sagitta=0, absolute=False, sides=8, angle=0, vertexColor='black', vertexColorKey=None, vertexSize=10, vertexSizeKey=None, vertexLabelKey=None, vertexGroupKey=None, vertexGroups=[], vertexMinGroup=None, vertexMaxGroup=None, showVertices=True, showVertexLabel=False, showVertexLegend=False, edgeColor='red', edgeColorKey=None, edgeWidth=1, edgeWidthKey=None, edgeLabelKey=None, edgeGroupKey=None, edgeGroups=[], edgeMinGroup=None, edgeMaxGroup=None, showEdges=True, showEdgeLabel=False, showEdgeLegend=False, colorScale='viridis', renderer=None, width=950, height=500, xAxis=False, yAxis=False, zAxis=False, axisSize=1, backgroundColor='rgba(0,0,0,0)', marginLeft=0, marginRight=0, marginTop=20, marginBottom=0, camera=[-1.25, -1.25, 1.25], center=[0, 0, 0], up=[0, 0, 1], projection='perspective', tolerance=0.0001, silent=False)

Shows the graph using Plotly.

Parameters
*graphstopologic_core.Graph

One or more toplogic_core.graph objects.

sagittafloat , optional

The length of the sagitta. In mathematics, the sagitta is the line connecting the center of a chord to the apex (or highest point) of the arc subtended by that chord. Default is 0 which means a straight edge is drawn instead of an arc. Default is 0.

absolutebool , optional

If set to True, the sagitta length is treated as an absolute value. Otherwise, it is treated as a ratio based on the length of the edge. Default is False. For example, if the length of the edge is 10, the sagitta is set to 0.5, and absolute is set to False, the sagitta length will be 5. Default is True.

sidesint , optional

The number of sides of the arc. Default is 8.

anglefloat, optional

An additional angle in degrees to rotate arcs (where sagitta is more than 0). Default is 0.

vertexColorstr , optional

The desired color of the output vertices. This can be any plotly color string and may be specified as: - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is “black”.

vertexColorKeystr , optional

The dictionary key under which to find the vertex color. Default is None.

vertexSizefloat , optional

The desired size of the vertices. Default is 1.1.

vertexSizeKeystr , optional

The dictionary key under which to find the vertex size. Default is None.

vertexLabelKeystr , optional

The dictionary key to use to display the vertex label. Default is None.

vertexGroupKeystr , optional

The dictionary key to use to display the vertex group. Default is None.

vertexGroupslist , optional

The list of vertex groups against which to index the color of the vertex. Default is [].

vertexMinGroupint or float , optional

For numeric vertexGroups, vertexMinGroup is the desired minimum value for the scaling of colors. This should match the type of value associated with the vertexGroupKey. If set to None, it is set to the minimum value in vertexGroups. Default is None.

vertexMaxGroupint or float , optional

For numeric vertexGroups, vertexMaxGroup is the desired maximum value for the scaling of colors. This should match the type of value associated with the vertexGroupKey. If set to None, it is set to the maximum value in vertexGroups. Default is None.

showVerticesbool , optional

If set to True the vertices will be drawn. Otherwise, they will not be drawn. Default is True.

showVertexLabelbool , optional

If set to True, the vertex labels are shown permenantely on screen. Otherwise, they are not. Default is False.

showVertexLegendbool , optional

If set to True the vertex legend will be drawn. Otherwise, it will not be drawn. Default is False.

edgeColorstr , optional

The desired color of the output edges. This can be any plotly color string and may be specified as: - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is “black”.

edgeColorKeystr , optional

The dictionary key under which to find the edge color. Default is None.

edgeWidthfloat , optional

The desired thickness of the output edges. Default is 1.

edgeWidthKeystr , optional

The dictionary key under which to find the edge width. Default is None.

edgeLabelKeystr , optional

The dictionary key to use to display the edge label. Default is None.

edgeGroupKeystr , optional

The dictionary key to use to display the edge group. Default is None.

edgeGroupslist , optional

The list of edge groups against which to index the color of the edge. Default is [].

edgeMinGroupint or float , optional

For numeric edgeGroups, edgeMinGroup is the desired minimum value for the scaling of colors. This should match the type of value associated with the edgeGroupKey. If set to None, it is set to the minimum value in edgeGroups. Default is None.

edgeMaxGroupint or float , optional

For numeric edgeGroups, edgeMaxGroup is the desired maximum value for the scaling of colors. This should match the type of value associated with the edgeGroupKey. If set to None, it is set to the maximum value in edgeGroups. Default is None.

showEdgesbool , optional

If set to True the edges will be drawn. Otherwise, they will not be drawn. Default is True.

showEdgeLabelbool , optional

If set to True, the edge labels are shown permenantely on screen. Otherwise, they are not. Default is False.

showEdgeLegendbool , optional

If set to True the edge legend will be drawn. Otherwise, it will not be drawn. Default is False.

colorScalestr , optional

The desired type of plotly color scales to use (e.g. “Viridis”, “Plasma”). Default is “Viridis”. For a full list of names, see https://plotly.com/python/builtin-colorscales/.

rendererstr , optional

The desired renderer. See Plotly.Renderers(). If set to None, the code will attempt to discover the most suitable renderer. Default is None.

widthint , optional

The width in pixels of the figure. The default value is 950.

heightint , optional

The height in pixels of the figure. The default value is 950.

xAxisbool , optional

If set to True the x axis is drawn. Otherwise it is not drawn. Default is False.

yAxisbool , optional

If set to True the y axis is drawn. Otherwise it is not drawn. Default is False.

zAxisbool , optional

If set to True the z axis is drawn. Otherwise it is not drawn. Default is False.

axisSizefloat , optional

The size of the X, Y, Z, axes. Default is 1.

backgroundColorstr , optional

The desired color of the background. This can be any plotly color string and may be specified as: - A hex string (e.g. ‘#ff0000’) - An rgb/rgba string (e.g. ‘rgb(255,0,0)’) - An hsl/hsla string (e.g. ‘hsl(0,100%,50%)’) - An hsv/hsva string (e.g. ‘hsv(0,100%,100%)’) - A named CSS color. The default is “rgba(0,0,0,0)”.

marginLeftint , optional

The size in pixels of the left margin. The default value is 0.

marginRightint , optional

The size in pixels of the right margin. The default value is 0.

marginTopint , optional

The size in pixels of the top margin. The default value is 20.

marginBottomint , optional

The size in pixels of the bottom margin. The default value is 0.

cameralist , optional

The desired location of the camera). Default is [-1.25, -1.25, 1.25].

centerlist , optional

The desired center (camera target). Default is [0, 0, 0].

uplist , optional

The desired up vector. Default is [0, 0, 1].

projectionstr , optional

The desired type of projection. The options are “orthographic” or “perspective”. It is case insensitive. Default is “perspective”

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
None
static Size(graph)

Returns the graph size of the input graph. The graph size is its number of edges.

Parameters
graphtopologic_core.Graph

The input graph.

Returns
int

The number of edges in the input graph.

static SubGraphMatches(subGraph, superGraph, strict=False, vertexMatcher=None, vertexKey: str = 'id', mantissa: int = 6, tolerance: float = 0.0001)

Finds all subgraph matches from subgraph into supergraph. A match is valid if: - Each subgraph vertex maps to a unique supergraph vertex either by the vertexMatcher function or through matching the vertexKey values. - Each subgraph edge is represented either by an edge (if strict is set to True) or by an edge or a path (if strict is set to False) in the supergraph.

Parameters
subGraphtopologic_core.Graph

The input subgraph.

superGraphtopologic_core.Graph

The input supergraph.

strictbool , optional

If set to True, each subgraph edge must be represented by a single edge in the supergraph. Otherwise, an edge in the subgraph can be represented either with an edge or a path in the supergraph. Default is False.

vertexMatchercallable, optional

If specified, this function is called to check if two vertices are matched. The format must be vertex_matcher(sub_vertex, super_vertex, mantissa, tolerance) -> bool.

vertexKeystr , optional

The dictionary key to use for vertex matching if the vertexMatcher input parameter is set to None. Default is “id”.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
list

A list of subgraphs matched to the supergraph. Each vertex in the matched subgraph has a dictionary that merges the keys and values from both the subgraph and the supergraph.

static Subgraph(graph, vertices, vertexKey='cutVertex', edgeKey='cutEdge', tolerance=0.0001, silent: bool = False)

Returns a subgraph of the input graph as defined by the input vertices.

Parameters
graphtopologic_core.Graph

The input graph.

vertexKeystr , optional

The dictionary key under which to store the cut vertex status of each vertex. See https://en.wikipedia.org/wiki/Cut_(graph_theory). vertex cuts are indicated with a value of 1. Default is “cutVertex”.

edgeKeystr , optional

The dictionary key under which to store the cut edge status of each edge. See https://en.wikipedia.org/wiki/Cut_(graph_theory). edge cuts are indicated with a value of 1. Default is “cutVertex”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

The created subgraph.

static SymmetricDifference(graphA, graphB, vertexKeys, useCentroid: bool = False, tolerance: float = 0.001, silent: bool = False)

Find the symmetric difference (exclusive OR / XOR) of the two input graphs based on the input vertex keys. See https://en.wikipedia.org/wiki/Boolean_operation.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

vertexKeyslist or str , optional

The vertex dictionary key (str) or keys (list of str) to use to determine if two vertices are the same. If the vertexKeys are set to None or “loc” or “coord” or “xyz” (case insensitive), the distance between the vertices (within the tolerance) will be used to determine sameness. Default is None.

useCentroidbool , optional

This is not used here, but included for API consistency for boolean operations.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

the resultant graph. Vertex and edge dictionaries are not merged.

static Tietze(radius: float = 0.5, height: float = 1)

Creates a Tietze’s graph mapped on a mobius strip of the same input radius and height. See https://en.wikipedia.org/wiki/Tietze%27s_graph

Parameters
radiusfloat , optional

The desired radius of the mobius strip on which the graph is mapped. Default is 0.5.

heightfloat , optional

The desired height of the mobius strip on which the graph is mapped. Default is 1.

Returns
topologicpy.Graph

The created Tietze’s graph.

static TopologicalDistance(graph, vertexA, vertexB, tolerance=0.0001)

Returns the topological distance between the input vertices. See https://en.wikipedia.org/wiki/Distance_(graph_theory).

Parameters
graphtopologic_core.Graph

The input graph.

vertexAtopologic_core.Vertex

The first input vertex.

vertexBtopologic_core.Vertex

The second input vertex.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
int

The topological distance between the input vertices.

static Topology(graph)

Returns the topology (cluster) of the input graph

Parameters
graphtopologic_core.Graph

The input graph.

Returns
topologic_core.Cluster

The topology of the input graph.

static Tree(graph, vertex=None, ontology: bool = True, tolerance=0.0001)

Creates a tree graph version of the input graph rooted at the input vertex.

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex , optional

The input root vertex. If not set, the first vertex in the graph is set as the root vertex. Default is None.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Graph

The tree graph version of the input graph.

static Triples(graph, subjectKey: str = 'id', predicateKey: str = 'predicate', objectKey: str = 'id', includeMetadata: bool = True, tolerance: float = 0.0001, silent: bool = False)

Returns RDF-style triples from a TopologicPy Graph.

Parameters
graphtopologic_core.Graph

The input graph.

subjectKeystr , optional

Vertex dictionary key used to identify the subject. Default is “id”.

predicateKeystr , optional

Edge dictionary key used to identify the predicate. Default is “predicate”.

objectKeystr , optional

Vertex dictionary key used to identify the object. Default is “id”.

includeMetadatabool , optional

If set to True, vertex and edge metadata are included in each triple. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

A list of dictionaries in the form: {

“subject”: …, “predicate”: …, “object”: …

}

static Union(graphA, graphB, vertexKeys=None, useCentroid: bool = False, tolerance: float = 0.0001, silent: bool = False)

Union the two input graphs based on the input vertex keys. See https://en.wikipedia.org/wiki/Boolean_operation.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

vertexKeyslist or str , optional

The vertex dictionary key (str) or keys (list of str) to use to determine if two vertices are the same. If the vertexKeys are set to None or “loc” or “coord” or “xyz” (case insensitive), the distance between the vertices (within the tolerance) will be used to determine sameness. Default is None.

useCentroidbool , optional

If set to True, the coordinates of identical vertices from each graph are averaged to located the new merged vertex of the resulting graph. Otherwise, the coordinates of the vertex of the first input graph are used. Default is False.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

the resultant graph. Vertex and edge dictionaries are merged.

static VertexByKeyValue(graph, key: str = None, value=None, silent: bool = False)

Returns the first vertex in the input graph whose dictionary contains the input key/value pair.

Parameters
graphtopologic_core.Graph

The input graph.

keystr , optional

The dictionary key to search for. Default is None.

valueany , optional

The value to match. Default is None.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Vertex

The matching vertex, or None if no match is found.

static VertexDegree(graph, vertex, weightKey: str = None, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)

Returns the degree of the input vertex. See https://en.wikipedia.org/wiki/Degree_(graph_theory).

Parameters
graphtopologic_core.Graph

The input graph.

vertextopologic_core.Vertex

The input vertex.

weightKeystr , optional

If specified, the value in the connected edges’ dictionary specified by the weightKey string will be aggregated to calculate the vertex degree. If a numeric value cannot be retrieved from an edge, a value of 1 is used instead. This is used in weighted graphs. if weightKey is set to “Length” or “Distance”, the length of the edge will be used as its weight.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
int

The degree of the input vertex.

static Vertices(graph, sortBy: str = 'index', reverse: bool = False, silent: bool = False)

Returns the list of vertices in the input graph.

Parameters
graphtopologic_core.Graph

The input graph.

sortBystr , optional

The dictionary key to use for sorting the returned edges. Special strings include “length” and “distance” to sort by the length of the edge. Default is “index”.

reversebool , optional

If set to True, the sorted list is reversed. This has no effect if the sortBy parameter is not set. Default is False.

silentbool, optional

Isilent : bool, optional If set to True, all errors and warnings are suppressed. Default is False.

Returns
list

The list of vertices in the input graph.

static VisibilityGraph(face, viewpointsA=None, viewpointsB=None, ontology: bool = True, tolerance=0.0001)

Creates a 2D visibility graph.

Parameters
facetopologic_core.Face

The input boundary. View edges will be clipped to this face. The holes in the face are used as the obstacles

viewpointsAlist , optional

The first input list of viewpoints (vertices). Visibility edges will connect these veritces to viewpointsB. If set to None, this parameters will be set to all vertices of the input face. Default is None.

viewpointsBlist , optional

The input list of viewpoints (vertices). Visibility edges will connect these vertices to viewpointsA. If set to None, this parameters will be set to all vertices of the input face. Default is None.

ontologybool , optional

If set to True, ontology metadata and semantic class annotations are added to the created/imported topology or graph. Default is True.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

Returns
topologic_core.Graph

The visibility graph.

static WLFeatures(graph, key: str = None, iterations: int = 2, silent: bool = False)

Returns a Weisfeiler-Lehman subtree features for a Graph. See https://en.wikipedia.org/wiki/Weisfeiler_Leman_graph_isomorphism_test

Parameters
graphtopologic_core.Graph

The input graph.

keystr , optional

The vertex key to use as an initial label. Default is None which means the vertex degree is used instead.

iterationsint , optional

The desired number of WL iterations. (non-negative int). Default is 2.

silentbool, optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
dict

{feature_id: count} where feature_id is an int representing a WL label.

static WLKernel(graphA, graphB, key: str = None, iterations: int = 2, normalize: bool = True, mantissa: int = 6, silent: bool = False)

Returns a cosine-normalized Weisfeiler-Lehman kernel between two graphs. See https://en.wikipedia.org/wiki/Weisfeiler_Leman_graph_isomorphism_test

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

keystr , optional

The vertex key to use as an initial label. Default is None which means the vertex degree is used instead.

iterationsint , optional

The desired number of WL iterations. (non-negative int). Default is 2.

normalizebool , optional

if set to True, the returned value is normalized between 0 and 1. Default is True.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

Returns
float

The cosine-normalized Weisfeiler-Lehman kernel

static WeightedJaccardSimilarity(graphA, graphB, vertexA, vertexB, vertexIDKey='id', edgeWeightKey=None, mantissa=6, silent=False)

Computes the weighted Jaccard similarity between two vertices based on their neighbors and edge weights. Accepts either one graph (both vertices are in the same graph) or two graphs (each vertex is in a separate graph).

Parameters
graphAtopologic_core.Graph

The first graph

graphBtopologic_core.Graph

The second graph (this can be the same as the first graph)

vertexAtopologic_core.Vertex

The first vertex.

vertexBtopologic_core.Vertex

The second vertex.

vertexIDKeystr , optional

The dictionary key under which to find the unique vertex ID. Default is “id”.

edgeWeightKeystr , optional

The dictionary key under which to find the weight of the edge for weighted graphs. If this parameter is specified as “length” or “distance” then the length of the edge is used as its weight. The default is None which means all edges are treated as if they have a weight of 1.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
float

Weighted Jaccard similarity score between 0 (no overlap) and 1 (perfect match).

static WikiString(graph, vertexKey: str = 'id', vertexLabelKey: str = 'label', vertexTypeKey: str = 'type', edgeKey: str = 'predicate', titleKey: str = None, includeDictionaries: bool = True, includeBacklinks: bool = True, pageSeparator: str = '\n\n---\n\n', tolerance: float = 0.0001, silent: bool = False)

Returns a markdown wiki string representation of a TopologicPy Graph.

Each vertex becomes one markdown page. Edges become explicit wikilinks between pages. This is useful for Obsidian-style graph viewing and for LLM/GraphRAG-ready building knowledge corpora.

Parameters
graphtopologic_core.Graph

The input graph.

vertexKeystr , optional

Vertex dictionary key used as the stable page identifier. Default is “id”.

vertexLabelKeystr , optional

Vertex dictionary key used as the human-readable label. Default is “label”.

vertexTypeKeystr , optional

Vertex dictionary key used as the entity type. Default is “type”.

edgeKeystr , optional

Edge dictionary key used as the relationship/predicate label. Default is “predicate”.

titleKeystr , optional

Optional vertex dictionary key to use as the page title. If None, the title is derived from vertexLabelKey, vertexKey, or index. Default is None.

includeDictionariesbool , optional

If True, vertex dictionaries are written as property sections. Default is True.

includeBacklinksbool , optional

If True, incoming relations are also listed. Default is True.

pageSeparatorstr , optional

String used to separate pages in the returned markdown. Default is “nn—nn”.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If True, suppresses error and warning messages. Default is False.

Returns
str

A markdown string containing one wiki-style page per graph vertex.

static XOR(graphA, graphB, vertexKeys, useCentroid: bool = False, tolerance: float = 0.001, silent: bool = False)

Find the symmetric difference (exclusive OR / XOR) of the two input graphs based on an input vertex key. See https://en.wikipedia.org/wiki/Boolean_operation.

Parameters
graphAtopologic_core.Graph

The first input graph.

graphBtopologic_core.Graph

The second input graph.

vertexKeyslist or str , optional

The vertex dictionary key (str) or keys (list of str) to use to determine if two vertices are the same. If the vertexKeys are set to None or “loc” or “coord” or “xyz” (case insensitive), the distance between the vertices (within the tolerance) will be used to determine sameness. Default is None.

useCentroidbool , optional

This is not used here, but included for API consistency for boolean operations.

tolerancefloat , optional

The desired tolerance. Default is 0.0001.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
topologic_core.Graph

the resultant graph. Vertex and edge dictionaries are not merged.

class topologicpy.Graph.GraphQueueItem(edges)

Bases: tuple

Attributes
edges

Alias for field number 0

Methods

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

edges

Alias for field number 0

class topologicpy.Graph.MergingProcess(message_queue)

Bases: Process

Receive message from other processes and merging the result

Attributes
authkey
daemon

Return whether process is a daemon

exitcode

Return exit code of process or None if it has yet to stop

ident

Return identifier (PID) of process or None if it has yet to start

name
pid

Return identifier (PID) of process or None if it has yet to start

sentinel

Return a file descriptor (Unix) or handle (Windows) suitable for waiting for process termination.

Methods

close()

Close the Process object.

is_alive()

Return whether process is alive

join([timeout])

Wait until child process terminates

kill()

Terminate process; sends SIGKILL signal or uses TerminateProcess()

run()

Method to be run in sub-process; can be overridden in sub-class

start()

Start child process

terminate()

Terminate process; sends SIGTERM signal or uses TerminateProcess()

wait_message

wait_message()
class topologicpy.Graph.WorkerProcess(start_index, message_queue, used, face, sources, destinations, tolerance=0.0001)

Bases: Process

Creates a 2D navigation graph from a subset of sources and the list of destinations.

Attributes
authkey
daemon

Return whether process is a daemon

exitcode

Return exit code of process or None if it has yet to stop

ident

Return identifier (PID) of process or None if it has yet to start

name
pid

Return identifier (PID) of process or None if it has yet to start

sentinel

Return a file descriptor (Unix) or handle (Windows) suitable for waiting for process termination.

Methods

close()

Close the Process object.

is_alive()

Return whether process is alive

join([timeout])

Wait until child process terminates

kill()

Terminate process; sends SIGKILL signal or uses TerminateProcess()

run()

Method to be run in sub-process; can be overridden in sub-class

start()

Start child process

terminate()

Terminate process; sends SIGTERM signal or uses TerminateProcess()

run()

Method to be run in sub-process; can be overridden in sub-class

class topologicpy.Graph.WorkerProcessPool(num_workers, message_queue, used, face, sources, destinations, tolerance=0.0001)

Bases: object

Create and manage a list of Worker processes. Each worker process creates a 2D navigation graph.

Methods

join

startProcesses

stopProcesses

join()
startProcesses()
stopProcesses()