topologicpy.TGraph module
Axial and segment graphs
TGraph.AxialGraph(edges) represents each complete axial edge as a node and
each valid 3D contact as a graph edge. Projected crossings on different floors
do not connect. TGraph.SegmentGraph(edges) splits the input edges at contacts
and represents each resulting segment as a node. Both constructors require
straight, non-degenerate edges. Axial graphs accept overlapping collinear
interiors, duplicates and contained Edges, connecting each pair once while
retaining a separate node and originator for each supplied Edge. Segment graphs
require overlapping interiors to be merged before splitting.
They construct graphs from supplied geometry; generation belongs to
Face.AxialEdges (also available as Face.AxialLines).
Axial nodes retain the input edge. Segment nodes retain their generated segment,
with stable edge_id and parent_edge_id UUIDs and a live
parent_originator reference to the input edge. Segment connections store
angular_weight in quarter-turn units. Ordinary centrality methods can use
this key directly, and the angular wrappers recognize the segment graph tag.
Choice computes vertex betweenness; Integration computes closeness-based
integration. The latter does not implement Hillier-Hanson normalization.
Choice(normalize=False) returns raw counts, while True applies NetworkX
betweenness normalization.
For segment analysis, one may also provide a junction graph whose edges represent segments.
AngularChoice, AngularBetweenness, AngularIntegration, and
AngularConnectivity return values in active-edge order and store results
on those edges. With a SegmentGraph, they instead return active-node values
and store results on those nodes. This corrects the previous aliases, which operated on vertices.
Angular integration is closeness-based rather than NAIN. Segment connectivity
counts adjacent segments; it does not weight turning angles.
Closeness and betweenness accept an inclusive radius cutoff. None retains
global analysis. A cutoff uses hops without a weight key, accumulated costs
with a weight key, or quarter-turn units for angular analysis. Radius limits
source-to-destination shortest-path distance; it does not select an induced
neighborhood around each measured vertex. Normalization continues to use the
full graph order. These methods retain their undirected analysis convention.
Angular cost uses three-dimensional deflection: straight continuation costs zero in principle and a right turn costs one. Straight transitions use a positive floor of 1e-9 quarter-turn units to prevent zero-cost cycles in shortest-path counting. Consequently, even a straight transition is outside a radius of zero. Collinear paths can have very large unnormalized angular closeness values; the floor is an approximation rather than a physical cost.
Originators and colouring source geometry
An originator is distinct from the node’s display representation. AddVertex
accepts originator=topology and automatically links a topology input or
representation when no serialized link already exists. ByTopology and
BySpatialRelationships link the original topology even when its graph
representation is a representative point. ByVerticesEdges retains source
links independently of its storeRepresentations option.
The record stores originator, originator_id and originator_type;
the latter two are also mirrored in its dictionary. Identity uses the persistent
Topology.UUID stored under uuid on the source. Creating a link creates
that UUID if it is absent. Coincident geometry and graph indices never determine
identity. SetVertexOriginator assigns or clears a link, VertexOriginator
retrieves one source, and Originators returns sources in active-node order.
Copy, Subgraph, tree construction and spanning-tree construction retain
live source references. ToPython(includeRepresentations=True) and
FromPython preserve references in memory. Default JSON-compatible export
retains UUID/type metadata independently of mutable analysis dictionaries,
but cannot retain live Python objects. Reconnect with
Originators(graph, originators=source_topologies) after import. Distinct
objects with the same UUID are ambiguous and are rejected when resolving an
explicit source list. Geometry copies inheriting a UUID must therefore be
disambiguated by the caller. Synthetic nodes with no single source, such as
aggregate quotient nodes, require an explicit source link before transfer.
TransferDictionariesToOriginators merges selected node fields into source
dictionaries and preserves existing unrelated fields and UUIDs. Missing or
ambiguous links fail preflight before dictionary writes. For repeated sources,
identical values are accepted; conflicting values require an explicit
aggregation (first, last, sum, mean, min or max). overwrite=False keeps
existing source values. returnReport=True reports updates and errors.
Preflight is atomic; a backend write failure can report partial updates.
For example:
edges = Face.AxialEdges(face)
graph = TGraph.AxialGraph(edges=edges)
TGraph.BetweennessCentrality(graph, key="choice", colorKey="color")
coloured_edges = TGraph.TransferDictionariesToOriginators(
graph, keys=["choice", "color"])
- class topologicpy.TGraph.TGraph(directed: bool = False, allowSelfLoops: bool = True, allowParallelEdges: bool = False, dictionary: Optional[Dict[str, Any]] = None)
Bases:
objectA topology-first graph class.
TGraph stores graph incidence independently from geometry: - vertices are stable indexed records with Python dictionaries; - edges are src/dst index records with Python dictionaries; - optional vertex representations can be any topology; - optional edge representations can be topologic edges, wires, curves, or control data.
Methods
AABB(graph[, pad])Returns the axis-aligned bounding box of the active vertices in the input TGraph.
Returns a report indicating whether optional acceleration libraries are available.
AccessGraph(topology[, key, includeTypes, ...])Returns an access graph derived from the input topology.
AccessibilityCentrality(graph[, step, ...])Computes accessibility centrality values for the vertices of the input TGraph.
ActiveEdgeIndices(graph)Returns the indices of the active edges in the input TGraph.
ActiveVertexIndices(graph)Returns the indices of the active vertices in the input TGraph.
AddEdge(src[, dst, directed, dictionary, ...])Adds an edge to this TGraph and returns its index.
AddEdgeByIndex(index[, dictionary, ...])Adds an edge to this TGraph using a pair of vertex indices and returns the edge index.
AddVertex([dictionary, representation, ...])Adds a vertex to this TGraph and returns its index.
AddVertexByData(graph[, dictionary, x, y, ...])Adds a vertex with coordinate data to the input TGraph.
AddVertices(vertices[, dictionaries, ...])Adds multiple vertices to this TGraph and returns their indices.
AdjacencyDictionary(graph[, vertexLabelKey, ...])Returns an adjacency dictionary representation of the input TGraph.
AdjacencyList(graph[, mode])Returns an adjacency list representation of the input TGraph.
AdjacencyMatrix(graph[, vertexKey, reverse, ...])Returns an adjacency matrix representation of the input TGraph.
AdjacencyMatrixCSVString(graph[, vertexKey, ...])Serialize AdjacencyMatrix with Python's CSV quoting and escaping.
AdjacencyMatrixFigure(graph[, vertexKey, ...])Returns a Plotly table figure representing the adjacency matrix of the input TGraph.
AdjacentEdges(graph, edge)Returns the active edges adjacent to the input edge.
AdjacentIndices(graph, index[, mode])Returns the indices of vertices adjacent to the input vertex index.
AdjacentVertices(graph, vertex[, mode])Returns the vertices adjacent to the input vertex.
AdjacentVerticesByCompassDirection(graph, vertex)Returns adjacent vertices that lie in the requested compass direction from the input vertex.
AdjacentVerticesByVector(graph, vertex[, ...])Returns adjacent vertices that lie in the input vector direction from the input vertex.
AllPaths(graph, vertexA, vertexB[, ...])Returns simple paths between two vertices of the input TGraph within a time limit.
AnalysisContext(graph[, maxEntries, ...])Attach/retrieve a bounded reusable Python analysis context.
AngularBetweenness(graph[, normalize, ...])Alias AngularChoice; store the resulting values/colors on its segments.
AngularChoice(graph[, normalize, key, ...])Endpoint-aware angular choice, one result per original segment.
AngularConnectivity(graph[, key, colorKey, ...])Segment connectivity, stored on SegmentGraph nodes or other graph edges.
AngularIntegration(graph[, normalize, key, ...])Endpoint-aware angular integration, one result per original segment.
AngularTulipAnalysis(graph[, radius, ...])Compute Choice, Integration, NAIN and NACH in one Tulip traversal.
AnnotateIFC(graph[, ifcClass, ifcGUID, ...])Annotates a graph, vertex, or edge dictionary with IFC metadata.
AnnotateOntology(graph[, ontologyClass, ...])Annotates a graph, vertex, or edge dictionary with ontology metadata.
ApplyInferences(graph[, result, ...])Applies inferred semantic facts to TGraph dictionaries.
AverageClusteringCoefficient(graph[, ...])Returns the average local clustering coefficient of the input TGraph.
AxialGraph(edges[, tolerance, silent])Creates an undirected graph with one node per complete straight Edge.
BOTClassByOntologyClass(ontologyClass[, ...])Returns the BOT class corresponding to the input ontology class.
BOTGraph(graph, *args, **kwargs)Returns an RDFLib graph containing the BOT-compatible TTL representation of the TGraph.
BOTString(*args, **kwargs)Returns a BOT-compatible TTL string representation of the input TGraph.
BetweennessCentrality(graph[, weightKey, ...])Computes the betweenness centrality of the input TGraph and stores the result in the dictionary of each vertex or edge.
BetweennessPartition(graph[, n, m, key, ...])Partitions the input TGraph by iteratively removing high-betweenness edges.
BiconnectedComponents(graph[, silent])Returns the biconnected components of the input TGraph.
BreadthFirstSearch(graph, source[, mode])Returns the breadth-first traversal order from the input source vertex.
Bridges(graph, *[, key])Return matching records; optionally annotate all active records with 1/0.
ByAdjacencyDictionary([adjacencyDictionary, ...])Creates a TGraph from an adjacency dictionary.
ByAdjacencyList([adjacencyList, directed, ...])Creates a TGraph from an adjacency list.
ByAdjacencyMatrix([adjacencyMatrix, ...])Create a graph from a square finite numeric matrix.
ByAdjacencyMatrixCSVPath(path[, directed, ...])Read an adjacency matrix CSV with the same validation/options as ByAdjacencyMatrix.
ByBOTGraph(botGraph[, includeContext, xMin, ...])Creates a semantic TGraph projection from an RDFLib graph without losing RDF term identity.
ByBOTPath(path[, includeContext, xMin, ...])Creates a semantic TGraph projection from an RDF file.
ByCSVPath(path[, graphIDHeader, ...])Creates one or more TGraphs from a PyTorch/PyG-ready CSV folder.
ByCSVStrings(verticesCSVString, edgesCSVString)Creates a TGraph from lightweight TGraph record-CSV strings.
ByDepthmapSegmentData(segmentRows, ...[, silent])Import DepthmapX segment and oriented-connection CSV row dictionaries.
ByDictionaries([vertexDictionaries, ...])Creates a TGraph from vertex and edge dictionaries.
ByEdgeIndexPairs(order[, edgeIndexPairs, ...])Creates a TGraph from a vertex count and edge index pairs.
ByIFCFile(file[, importMode, clean, ...])Creates a TGraph from an IFC file.
ByIFCPath(path[, importMode, clean, ...])Creates a TGraph from an IFC file path.
ByJSONData(data[, ontology])Creates a TGraph from JSON-compatible Python data.
ByJSONDictionary(jsonDictionary[, xKey, ...])Creates a TGraph from a JSON-compatible dictionary.
ByJSONFile(file, **kwargs)Creates a TGraph from a JSON file object.
ByJSONPath(path[, silent])Creates a TGraph from a JSON file path.
ByJSONString(jsonString[, ontology])Creates a TGraph from a JSON string.
ByMeshData(vertices, edges[, ...])Creates a TGraph from mesh vertices, edges, and faces data.
ByNetworkXGraph(nxGraph[, vertexID, xKey, ...])Creates a TGraph from a NetworkX graph.
BySpatialRelationships(*topologies[, ...])Creates a TGraph of spatial relationships among the input topologies and annotates edges with GeoSPARQL predicates where applicable.
ByTopology(topology[, direct, ...])Creates a TGraph from a Topologic topology and selected relationship rules.
ByTriples([triples, directed, ...])Creates a directed TGraph from subject-relationship-object triples.
ByVerticesEdges([vertices, edges, directed, ...])Creates a TGraph from input vertices and edges.
CSVData(graph[, includeInactive])Returns lightweight TGraph record-CSV data.
CardinalityReport(graph[, vertexKey, ...])Returns a cardinality report for vertices in a TGraph.
CategoryByOntologyClass(ontologyClass[, ...])Returns the category corresponding to an ontology class.
Choice(graph[, normalize, key, mantissa, ...])Computes vertex choice using betweenness centrality.
ChromaticNumber(graph[, maxColors, silent])Returns an estimated chromatic number of the input TGraph.
ClearCompiled(graph)Clears the compiled cache of the input TGraph.
ClosenessCentrality(graph[, weightKey, ...])Computes the closeness centrality of the input TGraph and stores the result in the dictionary of each vertex or edge.
Color(graph[, oldKey, key, maxColors, tolerance])Assigns color values to graph elements using a selected dictionary key and color scale.
Community(graph[, key, colorKey, ...])Partitions the input TGraph into communities and stores both the community id and a corresponding colour in each active vertex dictionary.
CommunityPartition(graph[, key, colorKey, ...])Partitions the input TGraph into communities and stores the community id and corresponding colour in the dictionaries of active vertices.
Compare(graphA, graphB[, weightAttributes, ...])Compares two TGraphs and returns a similarity or difference report.
Compile(graph[, weightKey, force, useNumpy, ...])Prepare graph arrays, reusing bounded context entries when attached.
CompileInfo(graph)Returns a compact diagnostic report about the compiled cache.
CompiledAdjacency(graph[, mode, weightKey])Returns a compiled adjacency array for the requested adjacency mode.
Complement(graph[, ontology, tolerance, silent])Returns the complement graph of the input TGraph.
Complete(graph[, ontology, tolerance, silent])Returns the complete graph on the active vertices of the input TGraph.
Connect(graph, verticesA, verticesB[, tolerance])Connects every vertex in verticesA to every vertex in verticesB with an edge.
ConnectedComponents(graph[, mode, key])Return stable-index components; optionally annotate vertices and edges.
Connectivity(graph[, key, colorKey, mode, ...])Returns graph connectivity information for the input TGraph.
ContainsEdge(graph, edge[, tolerance, silent])Returns True if the input TGraph contains the input edge.
ContainsVertex(graph, vertex[, tolerance, ...])Returns True if the input TGraph contains the input vertex.
ContractEdge(graph, edge[, vertex, ...])Contracts an edge by merging its endpoints into one replacement vertex.
Coordinates(graph, vertex[, default])Returns the coordinates associated with a vertex of the input TGraph.
Copy(graph)Returns a copy of the input TGraph.
CutVertices(graph, *[, key])Return matching records; optionally annotate all active records with 1/0.
Degree(graph, index[, mode])Returns the degree of the input vertex.
DegreeCentrality(graph[, weightKey, ...])Computes degree centrality for the input TGraph and stores the result in the dictionary of each vertex or edge.
DegreeCentrality_old(graph[, mode, ...])Computes degree centrality values for the vertices of the input TGraph.
DegreeMatrix(graph[, mode])Returns the degree matrix of the input TGraph.
DegreeSequence(graph[, mode])Returns the degree sequence of the input TGraph.
Density(graph[, includeSelfLoops])Returns the density of the input TGraph.
Depth(graph, vertex[, source, mode, silent])Returns the traversal depth of vertices from a source vertex.
DepthFirstSearch(graph, source[, mode])Returns the depth-first traversal order from the input source vertex.
DepthMap(graph[, source, mode, key, silent, ...])Returns a dictionary mapping vertices to traversal depths.
DetachVertex(graph, *vertices[, silent])Removes all incident edges from the specified vertices while keeping the vertices active.
Diameter(graph[, mode])Returns the graph diameter of the input TGraph.
Dictionary(graph)Returns the dictionary of the input TGraph.
Difference(graphA, graphB[, silent, ...])Returns the graph difference between the first and second input TGraphs.
DisjointPaths(graph, source, target[, ...])Returns mutually disjoint paths between two vertices of the input TGraph.
Distance(graph, vertexA, vertexB[, ...])Returns the shortest-path distance between two vertices of the input TGraph.
Edge(graph[, index, vertexA, vertexB, ...])Returns an edge record from the input TGraph.
EdgeBetween(graph, src, dst[, directed, copy])Returns the first active edge between two input vertex indices.
EdgeConnectivity(graph, source, target[, ...])Returns the local edge connectivity between source and target.
EdgeDictionary(index[, copy])Returns the dictionary of an edge.
EdgeIndex(graph, edge)Returns the index of the input edge.
EdgeValue(edge, key[, default])Returns a dictionary value from an edge.
Edges(graph[, asTopologic, ...])Returns the edges of the input TGraph.
EdgesBetween(graph, src, dst[, directed, copy])Returns all active edges between two input vertex indices.
EdgesCSVString(graph[, includeInactive])Returns a lightweight CSV string of TGraph edge records.
EigenVectorCentrality(graph[, normalize, ...])Computes eigenvector centrality values for the vertices of the input TGraph.
EigenvectorCentrality(graph[, mode, ...])Computes eigenvector centrality values for the vertices of the input TGraph.
EnsureCompiled(graph[, weightKey, force, ...])Returns a valid compiled cache for the input TGraph, compiling it if needed.
ExplainInference(graph[, triple, subject, ...])Explains an asserted or inferred semantic fact for the TGraph.
ExportGraphToCSV(graph, *args, **kwargs)Deprecated compatibility alias for TGraph.ExportToCSV.
ExportGraphsToCSV(*args, **kwargs)Deprecated compatibility alias for TGraph.ExportToCSV.
ExportJSONLD(graph, path[, indent, silent])Exports the input TGraph to a JSON-LD file.
ExportTTL(graph, path[, silent])Exports the input TGraph to a TTL file.
ExportToAdjacencyMatrixCSV(adjacencyMatrix, path)Exports an adjacency matrix to a CSV file.
ExportToBOT(graph, path[, overwrite, silent])Exports the input TGraph to a BOT-compatible TTL file.
ExportToCSV(graph, path[, graphLabelKey, ...])Exports one TGraph or a list of TGraphs to a PyTorch/PyG-ready CSV folder.
ExportToGEXF(graph[, path, graphWidth, ...])Exports the input TGraph to a GEXF file.
ExportToGraphVizGraph(graph, path[, ...])Exports the input TGraph to a GraphViz graph object or file.
ExportToJSON(graph, path[, propertiesKey, ...])Exports the input TGraph to a JSON file.
ExportToJSONLD(graph, path[, indent, ...])Exports the input TGraph to a JSON-LD file.
ExportToRDF(graph, path[, overwrite, silent])Exports the input TGraph to an RDF/Turtle file.
ExportToWiki(graph, path[, overwrite, silent])Exports the input TGraph to a Wiki-compatible text file.
FiedlerVector(graph[, mantissa, silent])Returns the Fiedler vector of the input TGraph.
FiedlerVectorPartition(graph[, key, ...])Partitions the input TGraph using the Fiedler vector.
Figure(graph[, title, width, height, ...])Returns a Plotly figure representing the input TGraph.
FromPython(data[, ontology])Creates a TGraph from a Python data dictionary.
GlobalClusteringCoefficient(graph[, ...])Returns the global clustering coefficient of the input TGraph.
GraphVizGraph(graph[, directed, rankDir, ...])Return styled DOT text, or a graphviz.Source with asObject=True.
Guid(graph)Returns a persistent GUID for the input TGraph, creating one if needed.
HasEdge(graph, srcIndex, dstIndex[, directed])Returns True if an edge exists between two input vertex indices.
HasseDiagram(topology[, types, topDown, ...])Creates a Hasse diagram TGraph for the subtopologies of an input topology.
HopperKernel(graphA, graphB[, key, maxHops, ...])Returns a graph kernel similarity based on hop features.
Impose(graphA, graphB[, silent, vertexKeys, ...])Combine both graphs, letting B overwrite matching attributes.
Imprint(graphA, graphB[, silent, ...])Keep A's structure and overwrite matching attributes from B.
IncidentEdges(graph, index[, mode])Returns the active edges incident to the input vertex index.
IncomingEdges(graph, vertex)Returns the incoming edges of the input vertex.
IncomingVertices(graph, vertex)Returns the incoming adjacent vertices of the input vertex.
InducedSubgraph(graph, vertices[, silent])Returns the induced subgraph on the input vertex indices.
InferOntology(graph[, profile, ...])Runs ontology inference for the input TGraph.
Integration(graph[, normalize, key, ...])Compute closeness-based or Depthmap Hillier-Hanson integration.
Intersect(graphA, graphB[, silent, ...])Returns the graph intersection of two input TGraphs.
InvalidateCache(graph)Invalidates the compiled cache of the input TGraph.
IsBipartite(graph)Returns True if the input TGraph is bipartite.
IsCompiled(graph[, weightKey])Returns True if the input TGraph has a valid compiled cache.
IsComplete(graph[, includeSelfLoops])Returns True if the input TGraph is complete.
IsConnected(graph[, mode])Returns True if the input TGraph is connected.
IsDirected(graph)Returns True if the input TGraph is directed.
IsEmpty(graph)Returns True if the input TGraph has no active vertices or edges.
IsErdoesGallai(sequence[, silent])Returns True if the input degree sequence satisfies the Erdős-Gallai theorem.
IsInstance(graph)Returns True if the input object is a TGraph.
IsIsomorphic(graphA, graphB[, vertexIDKey, ...])Returns True if two input TGraphs are isomorphic under the requested constraints.
IsTree(graph)Returns True if the input TGraph is a tree.
IsolatedVertices(graph)Returns the isolated vertices of the input TGraph.
IsovistIntersectionGraph([isovists, ...])Construct an undirected graph of shared visible areas.
JSONData(graph[, includeRepresentations])Returns a JSON-compatible data dictionary representing the input TGraph.
JSONDataGraphCompatible(graph[, ...])Returns graph-compatible JSON data representing the input TGraph.
JSONLDData(graph[, includeVertices, ...])Returns JSON-LD data representing the input TGraph.
JSONLDString(graph[, indent])Returns a JSON-LD string representing the input TGraph.
JSONString(graph[, indent, ...])Returns a JSON string representing the input TGraph.
KHopsSubgraph(graph, vertices[, k, ...])Returns the induced subgraph of vertices within k hops of the input vertices.
KShortestPaths(graph, source, target[, k, ...])Return up to k distinct simple paths in increasing cost order (Yen).
Kernel(graphA, graphB[, method, key, ...])Returns a graph kernel similarity score between two input TGraphs.
KnowledgeGraph(graph, **kwargs)Returns a KnowledgeGraph view of the input TGraph.
KnowledgeGraphView(graph, **kwargs)Alias of TGraph.SemanticGraph for semantic graph visualisation.
Laplacian(graph[, mode, silent, normalized, ...])Return D-A, or the symmetric degree-normalized form.
Leaves(graph)Returns the leaf vertices of the input TGraph.
LineGraph(graph[, directed, ...])Returns the line graph of the input TGraph.
LocalClusteringCoefficient(graph[, ...])Computes local clustering coefficient values for the vertices of the input TGraph.
LongestPath(graph[, mode, silent, source, ...])Search for a longest simple path, optionally between fixed endpoints.
Match(graphA, graphB[, vertexKeys, ...])Returns subgraph matches of a pattern graph in a target graph.
MaximumDelta(graph[, mode, silent])Returns the maximum vertex degree of the input TGraph.
MaximumFlow(graph, source, sink[, ...])Return maximum flow, optionally with per-arc flow/residual details.
MeanDepth(graph[, sources, mode, key, silent])Return mean unweighted hop depths, sharing adjacency across sources.
Merge(graphA, graphB[, silent, vertexKeys, ...])Returns a merged graph from two input TGraphs.
MergeVertices(graph, *vertices[, ...])Merges several vertices into one target vertex and reconnects incident edges.
MeshData(graph[, active, ...])Returns mesh data representing the input TGraph.
MetricDistance(graph, vertexA, vertexB[, ...])Returns a metric distance between two input TGraphs.
MinimumCut(graph, source, target[, cut, ...])Returns the minimum source-target vertex or edge cut.
MinimumDelta(graph[, mode, silent])Returns the minimum vertex degree of the input TGraph.
MinimumSpanningTree(graph[, edgeKey])Returns a minimum spanning tree of the input TGraph.
NavigationGraph(face[, vertices, obstacles, ...])Returns a navigation graph derived from the input topology.
NearestVertex(graph[, vertex, x, y, z, ...])Returns the nearest TGraph vertex record to the input coordinates, TGraph vertex index, TGraph vertex record, Topologic vertex, or coordinate list.
NeedsSemanticSync(graph[, key])Returns True if the stored semantic fingerprint differs from the current one.
Neigborhood(graph[, vertices, k, ...])Returns a k-hop neighbourhood subgraph.
Neighborhood(graph[, vertices, k, ...])Correctly spelled alias for TGraph.Neigborhood.
NetworkXGraph(graph[, nodeIDKey, edgeIDKey, ...])Returns a NetworkX graph representation of the input TGraph.
NormalizeOntologyDictionaries(graph[, ...])Normalizes ontology dictionaries exclusively through Ontology.py.
OntologyAnnotateGraph(*args, **kwargs)Annotates graph, vertex, and edge dictionaries with ontology metadata.
OntologyCategory(graph[, element, index, ...])Returns the ontology category of a graph, vertex, or edge.
OntologyClass(graph[, element, index, ...])Returns the canonical ontology class of a graph, vertex, or edge.
OntologyClassByIFCClass(ifcClass[, defaultValue])Returns the canonical TopologicPy ontology class for an IFC class.
OntologyLabel(graph[, element, index, ...])Returns the ontology label of a graph, vertex, or edge.
OntologyTriples(graph[, includeVertices, ...])Returns canonical RDF triples for a TGraph.
OntologyURI(graph[, element, index, ...])Returns the ontology URI of a graph, vertex, or edge.
Order(graph)Returns the number of active vertices in the input TGraph.
Originators(graph[, originators, silent])Returns source topologies in active-node order, with None for missing links.
OutgoingEdges(graph, vertex)Returns the outgoing edges of the input vertex.
OutgoingVertices(graph, vertex)Returns the outgoing adjacent vertices of the input vertex.
PageRank(graph[, damping, iterations, ...])Computes PageRank values for the vertices of the input TGraph.
Partition(graph[, method, n, m, key, ...])Partitions the input graph and stores partition ids in dictionaries.
Path(graph, vertexA, vertexB[, tolerance, ...])Returns a least-cost path between two vertices of the input TGraph.
PathLength(graph, path[, mantissa, silent])Computes the geometric length of a TGraph path by summing the Euclidean distances between consecutive vertex coordinates.
ProofGraph(graph[, triple, subject, ...])Returns proof-graph data for a semantic fact.
ProofGraphData(graph[, triple, subject, ...])Returns Plotly-ready proof-graph data for a semantic fact.
ProofGraphFigure(graph[, triple, subject, ...])Returns a Plotly figure visualising a proof graph.
ProofGraphHTML(graph[, triple, subject, ...])Exports a proof-graph visualisation to an HTML file.
PropagateValues(graph[, sourceVertexKey, ...])Propagates dictionary values from source vertices to target vertices along selected edges.
PyvisGraph(graph[, height, width, directed, ...])Create a styled Pyvis Network; write HTML explicitly with write_html.
Quotient(topology[, topologyType, key, ...])Constructs the quotient graph induced by grouping TGraph vertices by a dictionary value.
RDFGraph(graph[, includeOntologyAxioms, ...])Returns an RDFLib graph for the input TGraph when RDFLib is available.
RDFString(*args, **kwargs)Returns an RDF/Turtle string representation of the input TGraph.
Reason(graph, **kwargs)Alias of TGraph.InferOntology.
RemoveEdge(edge[, silent])Removes an edge from this TGraph.
RemoveIsolatedEdges(graph[, silent, ...])Remove standalone edge components; optionally remove their vertices.
RemoveIsolatedVertices(graph[, mode, silent])Removes isolated vertices from the input TGraph.
RemoveVertex(vertex[, silent])Removes a vertex and its incident edges from this TGraph.
Reshape(graph[, shape, k, seed, iterations, ...])Repositions TGraph vertex coordinates using a simple layout algorithm.
SegmentGraph(edges[, tolerance, silent])Splits straight input Edges at 3D contacts and creates segment nodes.
SemanticDiff(graphA, graphB, **kwargs)Returns a semantic triple diff between two TGraphs or knowledge graphs.
SemanticFingerprint(graph[, ...])Returns a deterministic hash of the TGraph semantic triples.
SemanticGraph(graph, **kwargs)Returns the semantic KnowledgeGraph converted back to a TGraph view.
SemanticSummary(graph, **kwargs)Returns a summary of semantic content in the TGraph.
SetDictionary([dictionary])Sets the dictionary of this TGraph.
SetEdgeDictionary(index[, dictionary])Sets the dictionary of an edge in this TGraph.
SetEdgeValue(edge, key, value[, silent])Sets a dictionary value on an edge.
SetOntologyCategory(graph, category[, ...])Sets the ontology category of a graph, vertex, or edge.
SetOntologyClass(graph, ontologyClass[, ...])Sets a declared canonical ontology class on a graph, vertex, or edge.
SetOntologyLabel(graph, label[, element, index])Sets the ontology label of a graph, vertex, or edge.
SetOntologyURI(graph, uri[, element, index])Sets the explicit RDF resource URI of a graph, vertex, or edge.
SetVertexCoordinates(graph, vertexIndex[, ...])Sets the X, Y, Z coordinates of a TGraph vertex in-place.
SetVertexDictionary(index[, dictionary])Sets the dictionary of a vertex in this TGraph.
SetVertexOriginator(graph, vertex, originator)Links a node to its source topology independently of its representation.
SetVertexValue(vertex, key, value[, silent])Sets a dictionary value on a vertex.
ShortestPath(graph, source, target[, mode, ...])Returns a least-cost path between two vertices of the input TGraph.
ShortestPathTree(graph, source[, mode, ...])Returns a least-cost shortest-path tree rooted at the input source vertex.
ShortestPathViaVertices(graph, startVertex, ...)Returns a least-cost path that passes through required vertices in order.
ShortestPaths(graph, pairs[, mode, ...])Returns least-cost paths for all requested source-target pairs.
ShortestPathsFromSource(graph, source[, ...])Returns least-cost paths from one source vertex to the requested targets.
Show(*graphs[, sagitta, absolute, sides, ...])Displays a representation of the input TGraph.
Size(graph)Returns the number of active edges in the input TGraph.
SubGraphMatches(subGraph, superGraph[, ...])Returns subgraph matches of a pattern graph in a target graph.
Subgraph(graph, vertices[, induced])Returns a subgraph containing the requested vertices.
SymmetricDifference(graphA, graphB[, ...])Returns the symmetric difference of two input TGraphs.
SyncSemantics(graph[, key, applyInferences, ...])Updates semantic metadata and optionally applies inferred facts.
TTLString(graph[, includeVertices, ...])Returns a Turtle TTL string representing the input TGraph.
Tietze([radius, height])Creates Tietze's graph as a TGraph.
ToKnowledgeGraph(graph, **kwargs)Alias of TGraph.KnowledgeGraph.
ToPython(graph[, includeRepresentations])Returns a Python dictionary representation of the input TGraph.
TopologicEdge(graph, edge[, ...])Converts a TGraph edge to a Topologic edge.
TopologicVertex(graph, vertex[, ...])Converts a TGraph vertex to a Topologic vertex.
TopologicalDistance(graph, vertexA, vertexB)Returns the topological distance between two vertices of the input TGraph.
Topology(graph[, includeVertices, ...])Returns a Topologic topology representation of the input TGraph.
TransferDictionariesToOriginators(graph[, ...])Transfers active-node dictionary values to their originating topologies.
Tree(graph[, vertex, mode, silent])Returns a tree derived from the input TGraph.
Triples(graph, **kwargs)Returns relationship triples representing the input TGraph.
TurtleFromTriples(triples[, namespaces, ...])Returns Turtle generated by the canonical ontology serializer.
Union(graphA, graphB[, vertexKeys, ...])Returns the union of two input TGraphs.
ValidateOntology(graph[, requireClass, ...])Validates ontology metadata against the canonical ontology.
ValidateTTLString(ttlString[, silent])Validates a Turtle TTL string.
Vertex(graph, index[, copy, active, ...])Returns the vertex record at the input vertex index.
VertexByKeyValue(graph[, key, value, copy, ...])Returns the first active vertex whose dictionary contains the requested key-value pair.
VertexConnectivity(graph, source, target[, ...])Returns the local vertex connectivity between source and target.
VertexDegree(graph, vertex[, mode, silent, ...])Returns the degree of the input vertex.
VertexDictionary(index[, copy])Returns the dictionary of a vertex.
VertexDictionaryStatic(graph, index[, copy])Returns the dictionary of a vertex in the input TGraph.
VertexIndex(graph, vertex)Returns the index of the input vertex.
VertexOriginator(graph, vertex[, ...])Returns a node's source object, or resolves it by UUID against a list.
VertexValue(vertex, key[, default])Returns a dictionary value from a vertex.
Vertices(graph[, copy, asTopologic, ...])Returns the vertices of the input TGraph.
VerticesCSVString(graph[, includeInactive])Returns a lightweight CSV string of TGraph vertex records.
VisibilityGraph(face[, vertices, obstacles, ...])Returns a fast visibility graph derived from the input planar face.
WLFeatures(graph[, key, iterations, ...])Returns Weisfeiler-Lehman feature counts for the input TGraph.
WLKernel(graphA, graphB[, key, iterations, ...])Returns a Weisfeiler-Lehman kernel similarity score between two input TGraphs.
WarmUpAcceleration(graph[, mode, useNumba])Warms up optional acceleration paths used by TGraph algorithms.
WeightedJaccardSimilarity(graphA[, graphB, ...])Returns a weighted Jaccard similarity score between two input TGraphs.
WikiString(graph[, vertexKey, ...])Returns a Wiki-compatible string representation of the input TGraph.
WireByPath(graph, path[, ...])Converts an ordered TGraph path into a Topologic Wire.
XOR(graphA, graphB[, silent, vertexKeys, ...])Returns the symmetric difference of two input TGraphs.
- static AABB(graph: TGraph, pad: float = 0.0) Optional[Any]
Returns the axis-aligned bounding box of the active vertices in the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- padfloat , optional
The amount by which to pad the bounding box. Default is 0.0.
- Returns
- dict or topologicpy.BVH.AABB or None
The axis-aligned bounding box of the active graph vertices.
- static AccelerationReport() Dict[str, Any]
Returns a report indicating whether optional acceleration libraries are available.
- Parameters
- None
- Returns
- dict
A dictionary reporting optional acceleration library availability and versions.
- static AccessGraph(topology: Any, key: str = None, includeTypes: list = None, excludeTypes: list = None, viaSharedApertures: bool = False, toExteriorApertures: bool = False, useInternalVertex: bool = False, includeIsolatedVertices: bool = True, storeBREP: bool = False, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False) Optional[TGraph]
Returns an access graph derived from the input topology.
- Parameters
- topologyAny
The input Topologic topology.
- keystr , optional
The dictionary key to use. Default is None.
- includeTypeslist , optional
The topology or category types to include. Default is None.
- excludeTypeslist , optional
The topology or category types to exclude. Default is None.
- viaSharedAperturesbool , optional
If set to True, relationships through shared apertures are included. Default is False.
- toExteriorAperturesbool , optional
If set to True, relationships to exterior apertures are included. Default is False.
- useInternalVertexbool , optional
If set to True, an internal vertex is used when deriving topology coordinates. Default is False.
- includeIsolatedVerticesbool , optional
If set to True, isolated vertices are retained. Default is True.
- storeBREPbool , optional
If set to True, BREP strings are stored in dictionaries where possible. Default is False.
- mantissaint , optional
The number of decimal places to round numeric results 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
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static AccessibilityCentrality(graph: TGraph, 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) List[float]
Computes accessibility centrality values for the vertices of the input TGraph.
- Parameters
- graphTGraph
The input TGraph.
- stepint , optional
The input step value. Default is 2.
- normalizebool , optional
If set to True, returned values are normalized. Default is False.
- keystr , optional
The dictionary key under which values are stored. Default is “accessibility_centrality”.
- colorKeystr , optional
The dictionary key under which computed colors are stored. Default is “ac_color”.
- colorScalestr , optional
The Plotly color scale to use. Default is “viridis”.
- mantissaint , optional
The number of decimal places to round numeric results 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 resulting accessibility centrality values.
- static ActiveEdgeIndices(graph: TGraph) List[int]
Returns the indices of the active edges in the input TGraph.
This implementation reads the native edge records directly and deliberately avoids TGraph.Compile().
- Parameters
- graphTGraph
The input TGraph.
- Returns
- List[int]
The active stable edge indices in stored order.
- static ActiveVertexIndices(graph: TGraph) List[int]
Returns the indices of the active vertices in the input TGraph.
This implementation reads the native vertex records directly and deliberately avoids TGraph.Compile().
- Parameters
- graphTGraph
The input TGraph.
- Returns
- List[int]
The active stable vertex indices in stored order.
- AddEdge(src: Any, dst: Any = None, directed: Optional[bool] = None, dictionary: Optional[Dict[str, Any]] = None, representation: Any = None, transferVertexDictionaries: bool = False, transferEdgeDictionaries: bool = False, tolerance: float = 0.0001, silent: bool = False) Optional[int]
Adds an edge to this TGraph and returns its index.
- Parameters
- srcAny
The source vertex index.
- dstAny , optional
The destination vertex index. Default is None.
- directedOptional[bool] , optional
If set to True, graph edges are treated as directed. Default is None.
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- representationAny , optional
The optional representation object to store with the graph record. Default is None.
- transferVertexDictionariesbool , optional
If set to True, vertex dictionaries are transferred to created Topologic vertices. Default is False.
- transferEdgeDictionariesbool , optional
If set to True, edge dictionaries are transferred to created Topologic edges. 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
- int or None
The index of the created edge, or None if no edge was created.
- AddEdgeByIndex(index: Union[List[int], Tuple[int, int]], dictionary: Optional[Dict[str, Any]] = None, directed: Optional[bool] = None, representation: Any = None, silent: bool = False) Optional[int]
Adds an edge to this TGraph using a pair of vertex indices and returns the edge index.
- Parameters
- indexUnion[List[int], Tuple[int, int]]
The input index.
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- directedOptional[bool] , optional
If set to True, graph edges are treated as directed. Default is None.
- representationAny , optional
The optional representation object to store with the graph record. Default is None.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- int or None
The index of the created edge, or None if no edge was created.
- AddVertex(dictionary: Optional[Dict[str, Any]] = None, representation: Any = None, tolerance: float = 0.0001, silent: bool = False, originator: Any = None) int
Adds a vertex to this TGraph and returns its index.
- Parameters
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- representationAny , optional
The optional representation object to store with the graph record. 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.
- originatorAny , optional
The originating topology, independent of representation. If omitted, a topology input/representation is linked automatically when no serialized originator_id exists. A persistent UUID is created on the source if needed. Use SetVertexOriginator to explicitly clear a link.
- Returns
- int
The index of the created vertex.
- static AddVertexByData(graph: TGraph, dictionary: Optional[Dict[str, Any]] = None, x: float = None, y: float = None, z: float = None, silent: bool = False) Optional[TGraph]
Adds a vertex with coordinate data to the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- xfloat , optional
The X coordinate. Default is None.
- yfloat , optional
The Y coordinate. Default is None.
- zfloat , optional
The Z coordinate. Default is None.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- AddVertices(vertices: Iterable[Any], dictionaries: Optional[List[Dict[str, Any]]] = None, tolerance: float = 0.0001, silent: bool = False) List[int]
Adds multiple vertices to this TGraph and returns their indices.
- Parameters
- verticesIterable[Any]
The input vertices or vertex indices.
- dictionariesOptional[List[Dict[str, Any]]] , optional
The input list of dictionaries. 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
- list
The indices of the created vertices.
- static AdjacencyDictionary(graph: TGraph, vertexLabelKey: str = 'label', includeWeights: bool = False, edgeKey: str = 'weight') Dict[Any, List[Any]]
Returns an adjacency dictionary representation of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexLabelKeystr , optional
The dictionary key to use. Default is ‘label’.
- includeWeightsbool , optional
If set to True, edge weights are included in the output. Default is False.
- edgeKeystr , optional
The edge dictionary key to use. Default is ‘weight’.
- Returns
- Dict[Any, List[Any]]
The resulting adjacency dictionary list.
- static AdjacencyList(graph: TGraph, mode: str = 'out') List[List[int]]
Returns an adjacency list representation of the input TGraph.
This implementation operates directly on TGraph’s native incidence structures via AdjacentIndices and deliberately avoids TGraph.Compile().
- Parameters
- graphTGraph
The input TGraph.
- modestr, optional
The traversal or adjacency mode.
“out”: outgoing adjacency.
“in”: incoming adjacency.
“all”: adjacency in either direction.
Any value other than “in” or “all” is treated as “out”, matching the existing TGraph adjacency semantics.
Default is “out”.
- Returns
- List[List[int]]
The adjacency list. Rows correspond to active stable vertex indices in ascending order.
- static AdjacencyMatrix(graph: TGraph, vertexKey: str = None, reverse: bool = False, edgeKeyFwd: str = None, edgeKeyBwd: str = None, bidirKey: str = None, bidirectional: bool = None, useEdgeIndex: bool = False, useEdgeLength: bool = False, mantissa: int = 6, tolerance: float = 0.0001) List[List[Any]]
Returns an adjacency matrix representation of the input TGraph.
This implementation operates directly on TGraph’s native vertex and edge records and deliberately avoids TGraph.Compile().
- Parameters
- graphTGraph
The input TGraph.
- vertexKeystr, optional
The vertex dictionary key used to order vertices. Default is None.
- reversebool, optional
If True, reverse the output ordering. Default is False.
- edgeKeyFwdstr, optional
Edge dictionary key used for forward matrix values. Default is None.
- edgeKeyBwdstr, optional
Edge dictionary key used for backward matrix values. Default is None.
- bidirKeystr, optional
Edge dictionary key controlling bidirectionality. Default is None.
- bidirectionalbool, optional
Explicit default bidirectionality. Default is None.
- useEdgeIndexbool, optional
If True, matrix values are edge index + 1. Default is False.
- useEdgeLengthbool, optional
If True, matrix values are geometric edge lengths. Default is False.
- mantissaint, optional
Number of decimal places used for edge lengths. Default is 6.
- tolerancefloat, optional
The desired tolerance. Default is 0.0001.
- Returns
- List[List[Any]]
The resulting adjacency matrix.
- static AdjacencyMatrixCSVString(graph, vertexKey=None, reverse=False, edgeKeyFwd=None, edgeKeyBwd=None, bidirKey=None, bidirectional=None, useEdgeIndex=False, useEdgeLength=False, mantissa=6, tolerance=0.0001)
Serialize AdjacencyMatrix with Python’s CSV quoting and escaping.
- static AdjacencyMatrixFigure(graph: TGraph, 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.08)', title: str = None, cellSize: int = 24, fontFamily: str = 'Arial', fontSize: int = 12, fontColor: str = 'black', backgroundColor: str = 'white', headerColor: str = 'rgba(230,230,230,1)', reverse: bool = False, edgeKeyFwd: str = None, edgeKeyBwd: str = None, bidirKey: str = None, bidirectional: bool = True, useEdgeIndex: bool = False, useEdgeLength: bool = False, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)
Returns a Plotly table figure representing the adjacency matrix of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexKeystr , optional
The vertex dictionary key to use. Default is None.
- showZerobool , optional
If set to True, show zero are shown. Default is False.
- zeroCharstr , optional
The input zero char value. Default is ‘·’.
- zeroColorstr , optional
The color value to use. Default is ‘rgba(0,0,0,0)’.
- valueColorstr , optional
The color value to use. Default is ‘rgba(0,0,0,0.05)’.
- diagonalHighlightbool , optional
The input diagonal highlight value. Default is True.
- diagonalColorstr , optional
The color value to use. Default is ‘rgba(0,0,0,0.08)’.
- titlestr , optional
The optional figure title. Default is None.
- cellSizeint , optional
The input cell size value. Default is 24.
- fontFamilystr , optional
The input font family value. Default is ‘Arial’.
- fontSizeint , optional
The input font size value. Default is 12.
- fontColorstr , optional
The color value to use. Default is ‘black’.
- backgroundColorstr , optional
The color value to use. Default is ‘white’.
- headerColorstr , optional
The color value to use. Default is ‘rgba(230,230,230,1)’.
- reversebool , optional
If set to True, the output ordering is reversed. Default is False.
- edgeKeyFwdstr , optional
The input edge key fwd value. Default is None.
- edgeKeyBwdstr , optional
The input edge key bwd value. Default is None.
- bidirKeystr , optional
The dictionary key to use. Default is None.
- bidirectionalbool , optional
The input bidirectional value. Default is True.
- useEdgeIndexbool , optional
If set to True, the corresponding option is enabled. Default is False.
- useEdgeLengthbool , optional
If set to True, the corresponding option is enabled. Default is False.
- mantissaint , optional
The number of decimal places to round numeric results 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
- Any
The resulting adjacency matrix figure object or value.
- static AdjacentEdges(graph: TGraph, edge: Union[int, Dict[str, Any]]) List[Dict[str, Any]]
Returns the active edges adjacent to the input edge.
- Parameters
- graph‘TGraph’
The input TGraph.
- edgeUnion[int, Dict[str, Any]]
The input edge, edge index, or edge record.
- Returns
- List[Dict[str, Any]]
The resulting adjacent edges list.
- static AdjacentIndices(graph: TGraph, index: int, mode: str = 'out') List[int]
Returns the indices of vertices adjacent to the input vertex index.
This implementation traverses TGraph’s native incidence tables directly and deliberately avoids TGraph.Compile().
- Parameters
- graphTGraph
The input TGraph.
- indexint
The input vertex index.
- modestr, optional
The traversal or adjacency mode.
“out”: outgoing adjacency.
“in”: incoming adjacency.
“all”: adjacency in either direction.
Any value other than “in” or “all” is treated as “out”, matching the previous compiled-adjacency behaviour.
Default is “out”.
- Returns
- List[int]
The sorted stable indices of adjacent active vertices.
- static AdjacentVertices(graph: TGraph, vertex: Union[int, Dict[str, Any]], mode: str = 'out') List[Dict[str, Any]]
Returns the vertices adjacent to the input vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- Returns
- List[Dict[str, Any]]
The resulting adjacent vertices list.
- static AdjacentVerticesByCompassDirection(graph: TGraph, vertex: Any, compassDirection: str = 'Up', tolerance: float = 0.0001, silent: bool = False) Optional[List[Dict[str, Any]]]
Returns adjacent vertices that lie in the requested compass direction from the input vertex.
- Parameters
- graphTGraph
The input TGraph.
- vertexint or dict
The input vertex, vertex index, or vertex record.
- compassDirectionstr , optional
The compass direction. Common values include “Up”, “Down”, “North”, “South”, “East”, and “West”. Default is “Up”.
- tolerancefloat , optional
The direction tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list or None
The list of adjacent vertex records in the requested compass direction.
- static AdjacentVerticesByVector(graph: TGraph, vertex: Any, vector: list = [0, 0, 1], tolerance: float = 0.0001, silent: bool = False) Optional[List[Dict[str, Any]]]
Returns adjacent vertices that lie in the input vector direction from the input vertex.
- Parameters
- graphTGraph
The input TGraph.
- vertexint or dict
The input vertex, vertex index, or vertex record.
- vectorlist , optional
The target vector direction. Default is [0, 0, 1].
- tolerancefloat , optional
Angular comparison tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list or None
The list of adjacent vertex records in the requested direction.
- static AllPaths(graph: TGraph, vertexA, vertexB, timeLimit=10, silent: bool = False) List[List[int]]
Returns simple paths between two vertices of the input TGraph within a time limit.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexAAny
The first input vertex or vertex index.
- vertexBAny
The second input vertex or vertex index.
- timeLimitAny , optional
The maximum time, in seconds, allowed for the search. Default is 10.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- List[List[int]]
The resulting all paths list.
- static AnalysisContext(graph, maxEntries=128, maxBytes=67108864, maxSourceTrees=16, enabled=True, replace=False)
Attach/retrieve a bounded reusable Python analysis context.
Existing compatible methods reuse it transparently. No native traversal compilation is required. Changing context limits requires replace=True. Direct edits to relevant dictionaries are checked by content on each outer call. External opaque callbacks/geometry use uncached fallbacks or the context’s explicit token-based geometry API.
- static AngularBetweenness(graph, normalize=False, nxCompatible=True, key='angular_betweenness', colorKey='angular_betweenness_color', colorScale='viridis', mantissa=6, tolerance=0.001, silent=False, **kwargs)
Alias AngularChoice; store the resulting values/colors on its segments.
nxCompatible=True requests AngularChoice’s normalized results. Additional radius/mode/algorithm options are forwarded unchanged.
- static AngularChoice(graph: TGraph, normalize: bool = True, key: str = 'choice', mantissa: int = 6, silent: bool = False, radius: Optional[float] = None, mode: str = 'out', method: str = 'betweenness', radiusType: str = 'angular', weighting: Optional[str] = None, algorithm: str = 'exact', tulipBins: int = 1024) Optional[List[float]]
Endpoint-aware angular choice, one result per original segment.
method=”betweenness” preserves existing unordered-pair choice on undirected graphs and normalize=True applies NetworkX scaling. method=”depthmap” uses ordered-pair raw choice; normalize is ignored. method=”nach” uses log(choice+1)/log(TD+3) with ordered-pair choice and the same source/radius/weighting total angular depth TD. algorithm=”exact” (default) uses exact angles and splits tied paths. algorithm=”tulip” reproduces DepthmapX circular bins, metric tie order, and traversal-tree leaf accumulation. tulipBins defaults to 1024. Tulip supports undirected graphs with method=”depthmap” or “nach”, all three radius types, and length weighting. Its first-covered-state traversal matches DepthmapX; it does not use the exact algorithm’s Pareto path search. Tulip bins must be 4 to 1024 and finite radii whole nonnegative numbers, matching DepthmapX’s radius conversion. Segment order and endpoint orientation affect Tulip tie selection; preserve both when comparing imported DepthmapX networks.
radiusType is angular (quarter turns), metric (coordinate units, midpoint-to-midpoint along the route), or topological (segment steps). Radius is inclusive; None is global. Radius changes the allowed paths, never the angular optimization objective. Bounded metric/topological exact searches prefer least radius distance then hops on equal-angular paths. Exact angular/global searches retain the minimum-hop zero-turn rule. Tulip uses quantized turns and float32 metric queue ordering.
weighting=None uses unit demand; “length” uses origin length times destination length and includes half demand at each endpoint, matching Depthmap’s weighted choice convention. Weighted NACH is an extension of the formula, not an independently validated Depthmap result. Results are stored on SegmentGraph nodes or other graph edges.
- static AngularConnectivity(graph: TGraph, key: str = 'connectivity', colorKey: str = None, mode: str = 'all', normalize: bool = False, mantissa: int = 6, silent: bool = False, colorScale: str = 'viridis', method: str = 'degree') Optional[List[float]]
Segment connectivity, stored on SegmentGraph nodes or other graph edges.
method=”degree” preserves the default: count adjacent segments. method=”depthmap” sums permitted angular turn costs in quarter-turn units, matching Depthmap’s Angular Connectivity on undirected segment networks. mode is out, in, or all (default). Normalization is min-max rescaling.
- static AngularIntegration(graph: TGraph, normalize: bool = True, key: str = 'integration', mantissa: int = 6, silent: bool = False, radius: Optional[float] = None, mode: str = 'out', method: str = 'closeness', radiusType: str = 'angular', weighting: Optional[str] = None, algorithm: str = 'exact', tulipBins: int = 1024) Optional[List[float]]
Endpoint-aware angular integration, one result per original segment.
method=”closeness” preserves default angular closeness and optional min-max normalization. method=”depthmap” uses N**2/TD and returns -1 if TD<=1e-9. method=”nain” uses N**1.2/(TD+2), the shifted formula from the 13th Space Syntax Symposium Depthmap workshop. normalize is ignored for depthmap/nain. Isolated NAIN is undefined (-1); connected all-straight networks have finite shifted NAIN despite TD=0.
N includes the origin. With weighting=”length”, N becomes reachable total segment length and TD sums destination length times angular depth. This matches weighted Depthmap integration; weighted NAIN is an explicit formula extension and depends on coordinate units. Closeness uses destination weight mass/TD and the existing reachable-count correction.
radiusType is angular (quarter turns), metric (coordinate units along the route between segment midpoints), or topological (segment steps). Radius is inclusive; None is global. The objective stays angular. Bounded metric/topological ties prefer least radius distance then hops; angular/global ties retain the existing minimum-hop zero-turn rule. algorithm=”exact” preserves these defaults. algorithm=”tulip” uses the same DepthmapX traversal as Tulip Choice, with method=”depthmap” or “nain” only. It supports all radius types and length weighting on undirected graphs. Finite radii must be whole nonnegative numbers and tulipBins must be 4 to 1024. normalize is ignored in Tulip mode. Weighted NAIN remains a formula extension; raw weighted Integration follows DepthmapX. Preserve segment order and endpoint orientation. SegmentGraph results are stored on nodes; other graphs on edges.
- static AngularTulipAnalysis(graph: TGraph, radius: Optional[float] = None, radiusType: str = 'angular', weighting: Optional[str] = None, tulipBins: int = 1024, mode: str = 'out', mantissa: int = 6, writeValues: bool = True, colorize: bool = True, silent: bool = False) Optional[Dict[str, List[float]]]
Compute Choice, Integration, NAIN and NACH in one Tulip traversal.
Returns choice, integration, nain, nach, nodeCount, totalDepth and totalWeight arrays in segment order. Depth/mass include the origin; isolated origins have zero depth, and undefined Integration/NAIN -1. writeValues stores the four measures using their corresponding keys; colorize also stores bc_color and cc_color. Set writeValues=False for numerical results without dictionary or colour updates. Finite radii, weights, bin counts and graph support follow AngularChoice’s Tulip mode. Length-weighted NAIN/NACH remain formula extensions. No results are cached unless an AnalysisContext is attached. Relevant graph edits invalidate reused calculations through dependency checks.
- static AnnotateIFC(graph: TGraph, ifcClass: Optional[str] = None, ifcGUID: Optional[str] = None, ifcName: Optional[str] = None, source: Optional[str] = None, element: str = 'graph', index: Optional[int] = None) Optional[TGraph]
Annotates a graph, vertex, or edge dictionary with IFC metadata.
- Parameters
- graph‘TGraph’
The input TGraph.
- ifcClassOptional[str] , optional
The IFC class value. Default is None.
- ifcGUIDOptional[str] , optional
The IFC GlobalId value. Default is None.
- ifcNameOptional[str] , optional
The IFC name value. Default is None.
- sourceOptional[str] , optional
The input source vertex, vertex index, or source identifier. Default is None.
- elementstr , optional
The graph element to annotate or query. Valid values are typically “graph”, “vertex”, or “edge”. Default is ‘graph’.
- indexOptional[int] , optional
The input index. Default is None.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static AnnotateOntology(graph: TGraph, ontologyClass: Optional[str] = None, category: Optional[str] = None, label: Any = None, uri: Optional[str] = None, source: Any = None, derivedFrom: Any = None, generatedBy: Any = None, element: str = 'graph', index: Optional[int] = None, silent: bool = False, **kwargs) Optional[TGraph]
Annotates a graph, vertex, or edge dictionary with ontology metadata.
- static ApplyInferences(graph: TGraph, result=None, inferredGraph=None, namespacePrefix: str = 'inst', silent: bool = False, **kwargs)
Applies inferred semantic facts to TGraph dictionaries.
- static AverageClusteringCoefficient(graph: TGraph, mantissa: int = 6, silent: bool = False) float
Returns the average local clustering coefficient of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- float
The resulting average clustering coefficient value.
- static AxialGraph(edges, tolerance: float = 0.0001, silent: bool = False)
Creates an undirected graph with one node per complete straight Edge.
Nodes retain the original Edge as originator and representation. edge_id is its persistent UUID. Contacts are tested in 3D, including endpoints; projected crossings at different elevations do not connect. Overlapping collinear Edges are connected once per pair, including duplicates and contained Edges. Each retains its own node and originator; input Edges are not merged or modified. This constructor does not generate edges.
- static BOTClassByOntologyClass(ontologyClass: str, defaultValue: Any = None) Any
Returns the BOT class corresponding to the input ontology class.
- static BOTGraph(graph: TGraph, *args, **kwargs)
Returns an RDFLib graph containing the BOT-compatible TTL representation of the TGraph.
- Parameters
- graphTGraph
The input TGraph.
- *args, **kwargs
Additional arguments are passed to TGraph.BOTString.
- Returns
- rdflib.Graph or None
The BOT RDF graph, or None if RDFLib is unavailable or the graph is invalid.
- static BOTString(*args, **kwargs) Optional[str]
Returns a BOT-compatible TTL string representation of the input TGraph.
- Parameters
- *argsAny , optional
Additional positional arguments.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting botstring string.
- static BetweennessCentrality(graph: TGraph, 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', colorScaleMode: str = 'linear', mantissa: int = 6, tolerance: float = 0.001, silent: bool = False, radius: Optional[float] = None) Optional[List[float]]
Computes the betweenness centrality of the input TGraph and stores the result in the dictionary of each vertex or edge.
- Parameters
- graphTGraph
The input TGraph.
- 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 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 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. Uses internal endpoint orientations, with one result per original segment. Straight transitions cost zero quarter-turn units. Choice resolves zero-cost route ties by minimum transitions.
- angularWeightKeystr , optional
Retained for API compatibility. Angular mode computes costs on internal endpoint states rather than constructing a public line graph.
- 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”.
- colorScaleModestr , optional
The visual remapping used only for color generation. Supported values are “linear”, “log”, “log1p”, and “sqrt”. The actual betweenness centrality values stored under key are not modified. Default is “linear”.
- 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.
- radiusfloat , optional
Inclusive shortest-path cutoff. None means global analysis. Uses hop count when weightKey is None, otherwise accumulated edge cost; angular mode uses quarter-turn units. Must be finite and non-negative. Existing normalization uses the full graph order even with a cutoff. Directed inputs respect edge direction. Undirected inputs remain symmetric.
- Returns
- list or None
The list of centralities in the order matching the vertices or edges as requested.
- static BetweennessPartition(graph: TGraph, n: int = 2, m: int = 10, key: str = 'partition', tolerance: float = 0.0001, silent: bool = False) List[int]
Partitions the input TGraph by iteratively removing high-betweenness edges.
- Parameters
- graph‘TGraph’
The input TGraph.
- nint , optional
The input count, order, or requested number of groups. Default is 2.
- mint , optional
The input count or maximum number of iterations/removals. Default is 10.
- keystr , optional
The dictionary key to use. Default is ‘partition’.
- 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[int]
The resulting betweenness partition list.
- static BiconnectedComponents(graph: TGraph, silent: bool = False) List[List[int]]
Returns the biconnected components of the input TGraph.
The graph is treated as undirected, consistent with TGraph.CutVertices and TGraph.Bridges. Each returned component is a sorted list of stable vertex indices.
Articulation vertices can therefore appear in more than one component. Bridge edges produce two-vertex components, and isolated active vertices are returned as singleton components.
The implementation uses an iterative Tarjan edge-stack decomposition, avoiding Python recursion-depth limits on large graphs.
- Parameters
- graphTGraph
The input TGraph.
- silentbool , optional
If True, suppresses error messages. Default is False.
- Returns
- List[List[int]]
The biconnected components as lists of stable vertex indices.
- static BreadthFirstSearch(graph: TGraph, source: int, mode: str = 'out') List[int]
Returns the breadth-first traversal order from the input source vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- sourceint
The input source vertex, vertex index, or source identifier.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- Returns
- List[int]
The resulting breadth first search list.
- static Bridges(graph, *, key=None)
Return matching records; optionally annotate all active records with 1/0.
- static ByAdjacencyDictionary(adjacencyDictionary: Optional[Dict[Any, Iterable[Any]]] = None, directed: bool = False, allowSelfLoops: bool = True, allowParallelEdges: bool = False, dictionary: Optional[Dict[str, Any]] = None, vertexLabelKey: str = 'label', edgeWeightKey: str = 'weight', ontology: bool = True) TGraph
Creates a TGraph from an adjacency dictionary.
- Parameters
- adjacencyDictionaryOptional[Dict[Any, Iterable[Any]]] , optional
The input adjacency dictionary value. Default is None.
- directedbool , optional
If set to True, graph edges are treated as directed. Default is False.
- allowSelfLoopsbool , optional
If set to True, self-loop edges are allowed. Default is True.
- allowParallelEdgesbool , optional
If set to True, parallel edges are allowed. Default is False.
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- vertexLabelKeystr , optional
The dictionary key to use. Default is ‘label’.
- edgeWeightKeystr , optional
The dictionary key to use. Default is ‘weight’.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- TGraph
The resulting TGraph, or None if the operation fails.
- static ByAdjacencyList(adjacencyList: Optional[List[Iterable[int]]] = None, directed: bool = False, allowSelfLoops: bool = True, allowParallelEdges: bool = False, dictionary: Optional[Dict[str, Any]] = None, ontology: bool = True) TGraph
Creates a TGraph from an adjacency list.
- Parameters
- adjacencyListOptional[List[Iterable[int]]] , optional
The input adjacency list value. Default is None.
- directedbool , optional
If set to True, graph edges are treated as directed. Default is False.
- allowSelfLoopsbool , optional
If set to True, self-loop edges are allowed. Default is True.
- allowParallelEdgesbool , optional
If set to True, parallel edges are allowed. Default is False.
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- TGraph
The resulting TGraph, or None if the operation fails.
- static ByAdjacencyMatrix(adjacencyMatrix=None, directed=False, allowSelfLoops=True, allowParallelEdges=False, dictionary=None, edgeKey='weight', ontology=True, *, dictionaries=None, vertexDictionaries=None, edgeKeyFwd=None, edgeKeyBwd=None)
Create a graph from a square finite numeric matrix.
dictionaries/vertexDictionaries provide one dictionary per row. Directed matrices create one arc per nonzero entry. In undirected mode, setting edgeKeyFwd/Bwd creates one edge per unordered pair, storing the upper and lower triangular values separately (including zero reverse capacity). Without these options, the existing incidence construction is preserved.
- static ByAdjacencyMatrixCSVPath(path, directed=False, silent=False, *, dictionaries=None, vertexDictionaries=None, edgeKey='weight', edgeKeyFwd=None, edgeKeyBwd=None, allowSelfLoops=True, allowParallelEdges=False, dictionary=None, ontology=True)
Read an adjacency matrix CSV with the same validation/options as ByAdjacencyMatrix.
Malformed input returns None with a diagnostic unless silent=True.
- 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) Optional[TGraph]
Creates a semantic TGraph projection from an RDFLib graph without losing RDF term identity.
- 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) Optional[TGraph]
Creates a semantic TGraph projection from an RDF file.
- static ByCSVPath(path: str, graphIDHeader: str = 'graph_id', graphLabelHeader: str = 'label', graphFeaturesHeader: str = 'feat', graphFeaturesKeys: list = None, edgeSRCHeader: str = 'src_id', edgeDSTHeader: str = 'dst_id', edgeLabelHeader: str = 'label', edgeTrainMaskHeader: str = 'train_mask', edgeValidateMaskHeader: str = 'val_mask', edgeTestMaskHeader: str = 'test_mask', edgeFeaturesHeader: str = 'feat', edgeFeaturesKeys: list = None, nodeIDHeader: str = 'node_id', nodeLabelHeader: str = 'label', nodeTrainMaskHeader: str = 'train_mask', nodeValidateMaskHeader: str = 'val_mask', nodeTestMaskHeader: str = 'test_mask', nodeFeaturesHeader: str = 'feat', nodeFeaturesKeys: list = None, nodeXHeader: str = 'x', nodeYHeader: str = 'y', nodeZHeader: str = 'z', directed: bool = False, allowSelfLoops: bool = True, allowParallelEdges: bool = True, ontology: bool = True, silent: bool = False) Optional[List[TGraph]]
Creates one or more TGraphs from a PyTorch/PyG-ready CSV folder.
The folder must contain:
graphs.csv
nodes.csv
edges.csv
The method returns a list of TGraphs. Each graph, vertex, and edge receives dictionaries containing labels, masks, features, and source IDs where present.
- Parameters
- pathstr
The input folder path containing graphs.csv, nodes.csv, and edges.csv.
- graphIDHeaderstr , optional
The graph ID column name. Default is “graph_id”.
- graphLabelHeaderstr , optional
The graph label column name. Default is “label”.
- graphFeaturesHeaderstr , optional
The graph feature column prefix. Default is “feat”.
- graphFeaturesKeyslist , optional
Graph feature keys. If None, feature columns are inferred from the prefix. Default is None.
- edgeSRCHeaderstr , optional
The edge source node ID column name. Default is “src_id”.
- edgeDSTHeaderstr , optional
The edge destination node ID column name. Default is “dst_id”.
- edgeLabelHeaderstr , optional
The edge label column name. Default is “label”.
- edgeTrainMaskHeaderstr , optional
The edge train mask column name. Default is “train_mask”.
- edgeValidateMaskHeaderstr , optional
The edge validation mask column name. Default is “val_mask”.
- edgeTestMaskHeaderstr , optional
The edge test mask column name. Default is “test_mask”.
- edgeFeaturesHeaderstr , optional
The edge feature column prefix. Default is “feat”.
- edgeFeaturesKeyslist , optional
Edge feature keys. If None, feature columns are inferred from the prefix. Default is None.
- nodeIDHeaderstr , optional
The node ID column name. Default is “node_id”.
- nodeLabelHeaderstr , optional
The node label column name. Default is “label”.
- nodeTrainMaskHeaderstr , optional
The node train mask column name. Default is “train_mask”.
- nodeValidateMaskHeaderstr , optional
The node validation mask column name. Default is “val_mask”.
- nodeTestMaskHeaderstr , optional
The node test mask column name. Default is “test_mask”.
- nodeFeaturesHeaderstr , optional
The node feature column prefix. Default is “feat”.
- nodeFeaturesKeyslist , optional
Node feature keys. If None, feature columns are inferred from the prefix. Default is None.
- nodeXHeaderstr , optional
The node X-coordinate column name. Default is “x”.
- nodeYHeaderstr , optional
The node Y-coordinate column name. Default is “y”.
- nodeZHeaderstr , optional
The node Z-coordinate column name. Default is “z”.
- directedbool , optional
If set to True, imported graph edges are treated as directed. Default is False.
- allowSelfLoopsbool , optional
If set to True, self-loop edges are allowed. Default is True.
- allowParallelEdgesbool , optional
If set to True, parallel edges are allowed. Default is True.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list or None
A list of imported TGraphs, or None if the folder is invalid.
- static ByCSVStrings(verticesCSVString: str, edgesCSVString: str, metadata: Optional[Dict[str, Any]] = None, directed: Optional[bool] = None, allowSelfLoops: Optional[bool] = None, allowParallelEdges: Optional[bool] = None) Optional[TGraph]
Creates a TGraph from lightweight TGraph record-CSV strings.
This method is intended for TGraph-native record serialisation. For PyTorch/PyG-ready datasets, use ByCSVPath and ExportToCSV.
- Parameters
- verticesCSVStringstr
The vertices CSV string.
- edgesCSVStringstr
The edges CSV string.
- metadatadict , optional
Metadata dictionary. Default is None.
- directedbool , optional
Overrides the graph directed value in metadata. Default is None.
- allowSelfLoopsbool , optional
Overrides the graph allowSelfLoops value in metadata. Default is None.
- allowParallelEdgesbool , optional
Overrides the graph allowParallelEdges value in metadata. Default is None.
- Returns
- TGraph or None
The created TGraph, or None if the operation fails.
- static ByDepthmapSegmentData(segmentRows, connectionRows, silent: bool = False)
Import DepthmapX segment and oriented-connection CSV row dictionaries.
Export shapegraph-map-csv and shapegraph-connections-csv from the same segment map, then pass lists from csv.DictReader. Ref IDs, endpoint orientation, saved Segment Length, turn weights and explicit links are preserved. No geometric reconstruction or tolerance-based relinking is performed. This returns an undirected analysis SegmentGraph with one node per segment; geometry is stored in dictionaries, without native originator Edges. Angular outputs are stored on its segment nodes.
- static ByDictionaries(vertexDictionaries: Optional[List[Dict[str, Any]]] = None, edgeDictionaries: Optional[List[Dict[str, Any]]] = None, directed: bool = False, allowSelfLoops: bool = True, allowParallelEdges: bool = False, dictionary: Optional[Dict[str, Any]] = None, ontology: bool = True) TGraph
Creates a TGraph from vertex and edge dictionaries.
- Parameters
- vertexDictionariesOptional[List[Dict[str, Any]]] , optional
The input vertex dictionaries value. Default is None.
- edgeDictionariesOptional[List[Dict[str, Any]]] , optional
The input edge dictionaries value. Default is None.
- directedbool , optional
If set to True, graph edges are treated as directed. Default is False.
- allowSelfLoopsbool , optional
If set to True, self-loop edges are allowed. Default is True.
- allowParallelEdgesbool , optional
If set to True, parallel edges are allowed. Default is False.
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- TGraph
The resulting TGraph, or None if the operation fails.
- static ByEdgeIndexPairs(order: int, edgeIndexPairs: Optional[Iterable[Union[Tuple[int, int], List[int]]]] = None, vertexDictionaries: Optional[List[Dict[str, Any]]] = None, edgeDictionaries: Optional[List[Dict[str, Any]]] = None, directed: bool = False, allowSelfLoops: bool = True, allowParallelEdges: bool = False, dictionary: Optional[Dict[str, Any]] = None, representations: Optional[Dict[str, Any]] = None, silent: bool = False, lean: bool = False, buildEdgeLookup: bool = True, ontology: bool = True) Optional[TGraph]
Creates a TGraph from a vertex count and edge index pairs.
- Parameters
- orderint
The input order value.
- edgeIndexPairsOptional[Iterable[Union[Tuple[int, int], List[int]]]] , optional
The input edge index pairs value. Default is None.
- vertexDictionariesOptional[List[Dict[str, Any]]] , optional
The input vertex dictionaries value. Default is None.
- edgeDictionariesOptional[List[Dict[str, Any]]] , optional
The input edge dictionaries value. Default is None.
- directedbool , optional
If set to True, graph edges are treated as directed. Default is False.
- allowSelfLoopsbool , optional
If set to True, self-loop edges are allowed. Default is True.
- allowParallelEdgesbool , optional
If set to True, parallel edges are allowed. Default is False.
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- representationsOptional[Dict[str, Any]] , optional
The input representations value. Default is None.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- leanbool , optional
The input lean value. Default is False.
- buildEdgeLookupbool , optional
The input build edge lookup value. Default is True.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static ByIFCFile(file, importMode: str = 'topology', clean: bool = False, storeBREP: bool = False, useInternalVertex: bool = False, includeTypes: list = None, strictIncludeTypes: bool = True, 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: str = 'color', edgeColorKey: str = 'color', colorScale: str = 'viridis', epsilon: float = 0.01, angTolerance: float = 0.1, tolerance: float = 0.0001, silent: bool = False) Optional[TGraph]
Creates a TGraph from an IFC file.
Supported relationship extraction is convention-based and includes IFC relationships with Relating* and Related* attributes, including but not limited to IfcRelAggregates, IfcRelNests, IfcRelAssignsToGroup, IfcRelContainedInSpatialStructure, IfcRelFillsElement, IfcRelVoidsElement, IfcRelDefinesByProperties, IfcRelAssociatesMaterial, and IfcRelDefinesByType.
- Parameters
- fileifcopenshell.file or str
The input IFC file object or path to an IFC file.
- importModestr , optional
Import mode. Options are “topology”, “geometry”, “triples”, and “semantic”. Default is “topology”.
- cleanbool , optional
If set to True, coplanar faces and collinear edges are removed in geometry mode where applicable. Default is False.
- storeBREPbool , optional
In geometry mode, if set to True, stores the BREP string of each imported topology under the key “BREP”. Default is False.
- useInternalVertexbool , optional
In geometry mode, if set to True, uses an internal vertex to represent each topology. Otherwise, uses its centroid. Default is False.
- includeTypeslist , optional
A list of IFC entity types to include as primary graph vertices. Default is None.
- strictIncludeTypesbool , optional
If set to True, only the entities that are in the includeTypes list are included in the graph. Default is True.
- 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.
- excludeRelslist , optional
A list of IFC relationship types to exclude. Default is None.
- dictionaryModestr , optional
Options are “none”, “basic”, “psets”, “all”, or “full”. 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 under which to store the calculated color. Default is “color”.
- edgeColorKeystr , optional
The desired edge dictionary key under which to store the calculated color. Default is “color”.
- colorScalestr , optional
The desired color scale name. Default is “viridis”.
- epsilonfloat , optional
Desired tolerance for removing coplanar faces. Default is 0.01.
- angTolerancefloat , optional
Angular tolerance for removing collinear edges. Default is 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
- TGraph or None
The created TGraph, or None if the operation fails.
- static ByIFCPath(path, importMode: str = 'topology', clean: bool = False, storeBREP: bool = False, useInternalVertex: bool = False, dictionaryMode: str = 'basic', includeTypes: list = None, strictIncludeTypes: bool = True, 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) Optional[TGraph]
Creates a TGraph from an IFC file path.
- Parameters
- pathstr
The input IFC file path.
- importModestr , optional
Import mode. Options are “topology”, “geometry”, “triples”, and “semantic”. Default is “topology”.
- cleanbool , optional
If set to True, coplanar faces and collinear edges are removed in geometry mode where applicable. Default is False.
- storeBREPbool , optional
In geometry mode, if set to True, stores the BREP string of each imported topology under the key “BREP”. Default is False.
- useInternalVertexbool , optional
In geometry mode, if set to True, uses an internal vertex to represent each topology. Otherwise, uses its centroid. Default is False.
- dictionaryModestr , optional
Options are “none”, “basic”, “psets”, “all”, or “full”. Default is “basic”.
- includeTypeslist , optional
A list of IFC entity types to include. Default is None.
- excludeTypeslist , optional
A list of IFC entity types to exclude. Default is None.
- includeRelslist , optional
A list of IFC relationship types to include. Default is None.
- excludeRelslist , optional
A list of IFC relationship types to exclude. Default is None.
- 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 under which to store the calculated color. Default is “color”.
- edgeColorKeystr , optional
The desired edge dictionary key under which to store the calculated color. Default is “color”.
- colorScalestr , optional
The desired color scale name. Default is “viridis”.
- epsilonfloat , optional
Desired tolerance for removing coplanar faces. Default is 0.01.
- angTolerancefloat , optional
Angular tolerance for removing collinear edges. Default is 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
- TGraph or None
The created TGraph, or None if the operation fails.
- static ByJSONData(data: Dict[str, Any], ontology: bool = True) Optional[TGraph]
Creates a TGraph from JSON-compatible Python data.
- Parameters
- dataDict[str, Any]
The input data dictionary.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static ByJSONDictionary(jsonDictionary: Dict[str, Any], 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) Optional[TGraph]
Creates a TGraph from a JSON-compatible dictionary.
- Parameters
- jsonDictionaryDict[str, Any]
The input json dictionary value.
- xKeystr , optional
The dictionary key to use. Default is ‘x’.
- yKeystr , optional
The dictionary key to use. Default is ‘y’.
- zKeystr , optional
The dictionary key to use. Default is ‘z’.
- vertexIDKeystr , optional
The dictionary key to use. Default is None.
- edgeSourceKeystr , optional
The dictionary key to use. Default is ‘source’.
- edgeTargetKeystr , optional
The dictionary key to use. Default is ‘target’.
- edgeIDKeystr , optional
The dictionary key to use. Default is None.
- graphPropsKeystr , optional
The dictionary key to use. Default is ‘properties’.
- verticesKeystr , optional
The dictionary key to use. Default is ‘vertices’.
- edgesKeystr , optional
The dictionary key to use. Default is ‘edges’.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- mantissaint , optional
The number of decimal places to round numeric results 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
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static ByJSONFile(file: Any, **kwargs) Optional[TGraph]
Creates a TGraph from a JSON file object.
- Parameters
- fileAny
The input file object.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static ByJSONPath(path: str, silent: bool = False, **kwargs) Optional[TGraph]
Creates a TGraph from a JSON file path.
- Parameters
- pathstr
The input file path.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static ByJSONString(jsonString: str, ontology: bool = True) Optional[TGraph]
Creates a TGraph from a JSON string.
- Parameters
- jsonStringstr
The input JSON string.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static ByMeshData(vertices, edges, vertexDictionaries=None, edgeDictionaries=None, ontology: bool = True, tolerance: float = 0.0001) TGraph
Creates a TGraph from mesh vertices, edges, and faces data.
- Parameters
- verticeslist
The input vertices or vertex indices.
- edgeslist
The input edges or edge records.
- vertexDictionariesAny , optional
The input vertex dictionaries value. Default is None.
- edgeDictionariesAny , optional
The input edge dictionaries value. Default is None.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- TGraph
The resulting TGraph, or None if the operation fails.
- static ByNetworkXGraph(nxGraph: Any, vertexID: str = 'id', xKey: str = 'x', yKey: str = 'y', zKey: str = 'z', coordsKey: str = 'coords', randomRange: Tuple[float, float] = (-1, 1), mantissa: int = 6, tolerance: float = 0.0001, directed: Optional[bool] = None, allowSelfLoops: bool = True, allowParallelEdges: bool = True, ontology: bool = True) Optional[TGraph]
Creates a TGraph from a NetworkX graph.
- Parameters
- nxGraphAny
The input nx graph value.
- vertexIDstr , optional
The input vertex id value. Default is ‘id’.
- xKeystr , optional
The dictionary key to use. Default is ‘x’.
- yKeystr , optional
The dictionary key to use. Default is ‘y’.
- zKeystr , optional
The dictionary key to use. Default is ‘z’.
- coordsKeystr , optional
The dictionary key to use. Default is ‘coords’.
- randomRangeTuple[float, float] , optional
The input random range value. Default is (-1, 1).
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- directedOptional[bool] , optional
If set to True, graph edges are treated as directed. Default is None.
- allowSelfLoopsbool , optional
If set to True, self-loop edges are allowed. Default is True.
- allowParallelEdgesbool , optional
If set to True, parallel edges are allowed. Default is True.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static BySpatialRelationships(*topologies, include: list = None, proximityValues: list = None, proximityLabels: list = None, 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', directed: bool = False, allowSelfLoops: bool = False, exactDisjoint: bool = False, maxDisjointPairs: int = 0, useBVH: bool = True, precomputeAABBs: bool = True, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False, preserveRepresentations: bool = False)
Creates a TGraph of spatial relationships among the input topologies and annotates edges with GeoSPARQL predicates where applicable.
This implementation is optimized for large topology sets. It uses AABB/BVH broad-phase pruning and calls expensive exact spatial predicates only for candidate pairs whose bounding boxes overlap. Exhaustive disjoint generation is disabled by default because it is O(n^2) and usually makes the graph unusably dense.
- Parameters
- *topologiestuple/list
Input TopologicPy topologies. Nested lists are flattened.
- includelist , optional
Spatial relations to include. Supported values: “contains”, “coveredBy”, “covers”, “crosses”, “disjoint”, “equals”, “intersects”, “overlaps”, “touches”, “within”, “proximity”. Default includes all except exhaustive disjoint is controlled by exactDisjoint/maxDisjointPairs.
- proximityValueslist , optional
Sorted or unsorted numeric distance thresholds. Default [1, 5, 10].
- proximityLabelslist , optional
Labels corresponding to proximityValues. Default [“near”, “intermediate”, “far”].
- useShortestDistancebool , optional
If True, uses Topology.ShortestDistance for proximity. This is much slower than centroid distance. Default False.
- useInternalVertexbool , optional
If True, graph vertices use Topology.InternalVertex. Otherwise centroid.
- vertexIDKeystr , optional
Vertex dictionary key storing sequential id. Default “id”.
- edgeKeyFwdstr , optional
Edge dictionary key storing forward relationship label. Default “relFwd”.
- edgeKeyBwdstr , optional
Edge dictionary key storing backward relationship label. Default “relBwd”.
- connectsKeystr , optional
Edge dictionary key storing [src, dst]. Default “connects”.
- storeBREPbool , optional
If True, stores BREP strings in vertex dictionaries. This is expensive.
- edgeColorKeystr , optional
Edge color dictionary key. Default “color”.
- colorScalestr , optional
Plotly/TopologicPy color scale. Default “viridis”.
- directedbool , optional
If True, creates directed TGraph edges. Default False.
- allowSelfLoopsbool , optional
If True, permits self-loops. Default False.
- exactDisjointbool , optional
If True, emits disjoint edges for non-overlapping AABB pairs. This is O(n^2) and can be very slow/large. Default False.
- maxDisjointPairsint , optional
Maximum number of disjoint edges to emit when exactDisjoint is True. 0 means no explicit cap. Default 0.
- useBVHbool , optional
If True, use BVH broad-phase for intersecting candidate pairs. Default True.
- precomputeAABBsbool , optional
If True, precomputes AABBs once. Default True.
- mantissaint , optional
Coordinate rounding precision. Default 6.
- tolerancefloat , optional
Geometric tolerance. Default 0.0001.
- silentbool , optional
If True, suppresses warnings. Default False.
- preserveRepresentationsbool , optional
If True, vertex representations retain the original input topologies. Coordinate dictionaries still use centroid/internal points. Default False preserves the existing point representations. References are retained without copying; storeBREP is separate serialization support.
- Returns
- TGraph or None
The resulting spatial relationship TGraph.
Notes
Exact topological relationships are evaluated before proximity, and proximity is emitted only as a fallback when no stronger DE-9IM / GeoSPARQL relation was found for that pair.
Edge dictionaries include: - relFwd / relBwd: human-readable relationship labels - ontology_class: top:Relationship - ontology_predicate: GeoSPARQL or TopologicPy predicate - inverse_predicate: inverse predicate where useful - relationship_family: GeoSPARQL-SF, GeoSPARQL-Egenhofer, TopologicPy - distance / proximity metadata for proximity edges
- 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: bool = False, host=None)
Creates a TGraph from a Topologic topology and selected relationship rules.
When host is a planar Face, retain only connections whose straight representative-to-representative segments lie within that Face, including its boundary and excluding holes. Vertices and their source identities are preserved. This optional navigation constraint is applied in a vectorized planar batch; omitted host preserves existing behavior.
- Parameters
- topologytopologic_core.Topology
The input Topologic topology.
- directbool, optional
If True, direct topological relationships are included.
- directAperturesbool, optional
If True, direct aperture relationships are included.
- viaSharedTopologiesbool, optional
If True, relationships through shared topologies are included.
- viaSharedAperturesbool, optional
If True, relationships through shared apertures are included.
- toExteriorTopologiesbool, optional
If True, relationships to exterior topologies are included.
- toExteriorAperturesbool, optional
If True, relationships to exterior apertures are included.
- toContentsbool, optional
If True, relationships to contents are included.
- toOutpostsbool, optional
If True, relationships to outposts are included.
- idKeystr, optional
Dictionary key used to identify outposts.
- outpostsKeystr, optional
Dictionary key containing outpost identifiers.
- vertexCategoryKeystr, optional
Dictionary key used for graph vertex categories.
- edgeCategoryKeystr, optional
Dictionary key used for graph edge categories.
- useInternalVertexbool, optional
If True, an internal vertex is used instead of center of mass.
- storeBREPbool, optional
If True, BREP information is stored where possible.
- ontologybool, optional
If True, ontology metadata is added or preserved.
- mantissaint, optional
Number of decimal places used for coordinates.
- tolerancefloat, optional
Desired geometric tolerance.
- silentbool, optional
If True, suppress warnings and errors.
- Returns
- TGraph or None
The resulting TGraph, or None if the operation fails.
- static ByTriples(triples: Optional[List[Tuple[Any, Any, Any]]] = None, directed: bool = True, allowSelfLoops: bool = True, allowParallelEdges: bool = False, dictionary: Optional[Dict[str, Any]] = None, vertexLabelKey: str = 'label', edgeLabelKey: str = 'label', ontology: bool = True) TGraph
Creates a directed TGraph from subject-relationship-object triples.
- Parameters
- triplesOptional[List[Tuple[Any, Any, Any]]] , optional
The input triples value. Default is None.
- directedbool , optional
If set to True, graph edges are treated as directed. Default is True.
- allowSelfLoopsbool , optional
If set to True, self-loop edges are allowed. Default is True.
- allowParallelEdgesbool , optional
If set to True, parallel edges are allowed. Default is False.
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- vertexLabelKeystr , optional
The dictionary key to use. Default is ‘label’.
- edgeLabelKeystr , optional
The dictionary key to use. Default is ‘label’.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- TGraph
The resulting TGraph, or None if the operation fails.
- static ByVerticesEdges(vertices: Optional[List[Any]] = None, edges: Optional[List[Any]] = None, directed: bool = False, allowSelfLoops: bool = True, allowParallelEdges: bool = False, dictionary: Optional[Dict[str, Any]] = None, vertexIDKey: str = 'id', edgeSRCKey: str = 'src', edgeDSTKey: str = 'dst', edgeSourceKey: str = 'source', edgeTargetKey: str = 'target', edgeSRCIDKey: str = 'src_id', edgeDSTIDKey: str = 'dst_id', edgeSourceIDKey: str = 'source_id', edgeTargetIDKey: str = 'target_id', storeRepresentations: bool = True, allowGeometricFallback: bool = True, ambiguousEndpointPolicy: str = 'warn', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False, ontology: bool = True) TGraph
Creates a TGraph from input vertices and edges.
Vertices may be Topologic vertices, TGraph vertex records, dictionaries, or other objects from which coordinates and dictionaries can be derived.
Edges may be Topologic edges, TGraph edge records, dictionaries containing endpoint information, or two-item endpoint sequences.
Edge endpoints are resolved in the following order:
Explicit source/destination vertex indices stored in the edge dictionary.
Explicit source/destination vertex IDs stored in the edge dictionary.
Source/target values interpreted as vertex IDs.
Endpoint objects interpreted directly as vertex indices.
Endpoint objects interpreted directly as vertex IDs.
Object identity with an input vertex or its stored representation.
Geometric matching of endpoint coordinates, if enabled.
- Parameters
- verticeslist , optional
The input vertices. Default is None.
- edgeslist , optional
The input edges. Default is None.
- directedbool , optional
If set to True, graph edges are treated as directed. Default is False.
- allowSelfLoopsbool , optional
If set to True, self-loop edges are allowed. Default is True.
- allowParallelEdgesbool , optional
If set to True, parallel edges are allowed. Default is False.
- dictionarydict , optional
The graph dictionary. Default is None.
- vertexIDKeystr , optional
The vertex dictionary key used as a semantic vertex ID. Default is “id”.
- edgeSRCKeystr , optional
The edge dictionary key used for the source vertex index. Default is “src”.
- edgeDSTKeystr , optional
The edge dictionary key used for the destination vertex index. Default is “dst”.
- edgeSourceKeystr , optional
An alternative edge dictionary source key. Default is “source”.
- edgeTargetKeystr , optional
An alternative edge dictionary destination key. Default is “target”.
- edgeSRCIDKeystr , optional
The edge dictionary key used for a source vertex ID. Default is “src_id”.
- edgeDSTIDKeystr , optional
The edge dictionary key used for a destination vertex ID. Default is “dst_id”.
- edgeSourceIDKeystr , optional
An alternative source vertex ID key. Default is “source_id”.
- edgeTargetIDKeystr , optional
An alternative destination vertex ID key. Default is “target_id”.
- storeRepresentationsbool , optional
If set to True, source objects are retained as graph representations where appropriate. Default is True.
- allowGeometricFallbackbool , optional
If set to True, unresolved edge endpoints may be matched to vertices geometrically. Default is True.
- ambiguousEndpointPolicystr , optional
Policy used when geometric matching finds more than one vertex. Valid values are “warn”, “skip”, “first”, and “error”. Default is “warn”.
- mantissaint , optional
The number of decimal places used for coordinates. Default is 6.
- tolerancefloat , optional
The geometric matching tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- TGraph
The resulting TGraph.
- static CSVData(graph: TGraph, includeInactive: bool = False) Dict[str, Any]
Returns lightweight TGraph record-CSV data.
This method is intended for TGraph-native record serialisation. For PyTorch/PyG-ready datasets, use ByCSVPath and ExportToCSV.
- Parameters
- graphTGraph
The input TGraph.
- includeInactivebool , optional
If set to True, inactive vertices and edges are included. Default is False.
- Returns
- dict
A dictionary containing metadata, vertices_csv, and edges_csv.
- static CardinalityReport(graph: TGraph, vertexKey: str = 'id', edgeKey: str = 'predicate', predicates: list = None, direction: str = 'both', includeZero: bool = True, tolerance: float = 0.0001, silent: bool = False) Optional[List[Dict[str, Any]]]
Returns a cardinality report for vertices in a TGraph.
This method counts how many incident edges of each selected predicate are connected to each active vertex.
- Parameters
- graphTGraph
The input TGraph.
- 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
Edge direction to count. Valid values are “in”, “out”, and “both”. Default is “both”.
- includeZerobool , optional
If set to True, include vertices with zero matching edges. Default is True.
- tolerancefloat , optional
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 or None
A list of dictionaries, one row per reported vertex.
- static CategoryByOntologyClass(ontologyClass: str, defaultValue: Any = None) Any
Returns the category corresponding to an ontology class.
- static Choice(graph: TGraph, normalize: bool = True, key: str = 'choice', mantissa: int = 6, silent: bool = False, radius: Optional[float] = None) List[float]
Computes vertex choice using betweenness centrality.
- Parameters
- graph‘TGraph’
The input TGraph.
- normalizebool , optional
If True, uses NetworkX betweenness normalization; otherwise returns raw shortest-path counts. Default is True.
- keystr , optional
The dictionary key to use. Default is ‘choice’.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- radiusfloat , optional
Inclusive hop cutoff; None means global analysis.
- Returns
- List[float]
The resulting choice list.
- static ChromaticNumber(graph: TGraph, maxColors: int = None, silent: bool = False) Optional[int]
Returns an estimated chromatic number of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- maxColorsint , optional
The input max colors value. Default is None.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[int]
The resulting chromatic number index or count.
- static ClearCompiled(graph: TGraph) Optional[TGraph]
Clears the compiled cache of the input TGraph.
- Parameters
- graphTGraph
The input TGraph.
- Returns
- TGraph or None
The input TGraph with its compiled cache cleared, or None if invalid.
- static ClosenessCentrality(graph: TGraph, 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, radius: Optional[float] = None, mode: str = 'out') Optional[List[float]]
Computes the closeness centrality of the input TGraph and stores the result in the dictionary of each vertex or edge.
- Parameters
- graphTGraph
The input TGraph.
- 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 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 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. Uses internal endpoint orientations, with one result per original segment. Straight transitions cost zero quarter-turn units. Choice resolves zero-cost route ties by minimum transitions.
- angularWeightKeystr , optional
Retained for API compatibility. Angular mode computes costs on internal endpoint states rather than constructing a public line graph.
- 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 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.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- radiusfloat , optional
Inclusive shortest-path cutoff. None means global analysis. Uses hop count when weightKey is None, otherwise accumulated edge cost; angular mode uses quarter-turn units. Must be finite and non-negative. Existing normalization uses the full graph order even with a cutoff. Directed inputs respect edge direction. Undirected inputs remain symmetric.
- modestr, optional
Directed traversal: “out” (default), “in”, or “all”. The nxCompatible flag controls normalization, not traversal direction. Zero total distance with reachable peers is undefined: returns -1, excluded from normalization and coloured grey. Isolated nodes return 0.
- Returns
- list or None
The list of centralities in the order matching the vertices or edges as requested.
- static Color(graph: TGraph, oldKey: str = 'color', key: str = 'color', maxColors: int = None, tolerance: float = 0.0001) Optional[TGraph]
Assigns color values to graph elements using a selected dictionary key and color scale.
- Parameters
- graph‘TGraph’
The input TGraph.
- oldKeystr , optional
The dictionary key to use. Default is ‘color’.
- keystr , optional
The dictionary key to use. Default is ‘color’.
- maxColorsint , optional
The input max colors value. Default is None.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static Community(graph: TGraph, key: str = 'community', colorKey: str = 'cp_color', colorScale: str = 'viridis', algorithm: str = 'louvain', weightKey: str = None, nClusters: int = None, maxIterations: int = 100, seed: int = 17, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False) List[int]
Partitions the input TGraph into communities and stores both the community id and a corresponding colour in each active vertex dictionary.
- Parameters
- graphTGraph
The input TGraph.
- keystr , optional
The dictionary key under which to store the community id. Default is “community”.
- colorKeystr , optional
The dictionary key under which to store the community colour. Default is “cp_color”.
- colorScalestr , optional
The Plotly colour scale to use. Default is “viridis”.
- algorithmstr , optional
The community detection algorithm. Valid values are: “louvain”, “spectral”, “infomap”, and “propagation”. Default is “louvain”.
- weightKeystr , optional
The edge dictionary key to use as edge weight. If set to None, each edge has weight 1. If set to “length” or “distance”, geometric edge length is used. Default is None.
- nClustersint , optional
Desired number of clusters for spectral clustering. If set to None, the number of clusters is estimated from the eigengap. Ignored by the other algorithms. Default is None.
- maxIterationsint , optional
Maximum number of iterations. Default is 100.
- seedint , optional
Random seed used by stochastic or seeded algorithms. Default is 17.
- mantissaint , optional
The number of decimal places to round numeric results to. Community ids are stored as integers. 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 resulting community id list in active-vertex order.
- static CommunityPartition(graph: TGraph, key: str = 'community', colorKey: str = 'cp_color', colorScale: str = 'viridis', algorithm: str = 'louvain', weightKey: str = None, nClusters: int = None, maxIterations: int = 100, seed: int = 17, tolerance: float = 0.0001, silent: bool = False) List[int]
Partitions the input TGraph into communities and stores the community id and corresponding colour in the dictionaries of active vertices. Active edge dictionaries are also annotated with community information and an “inter_community” boolean.
- Parameters
- graphTGraph
The input TGraph.
- keystr , optional
The dictionary key under which to store the community id. Default is “community”.
- colorKeystr , optional
The dictionary key under which to store the community colour. Default is “cp_color”.
- colorScalestr , optional
The Plotly colour scale to use when assigning colours. Default is “viridis”.
- algorithmstr , optional
The community detection algorithm. Valid values are:
“louvain”: Uses python-igraph’s community_multilevel algorithm.
“spectral”: Uses spectral clustering on the graph Laplacian followed
by k-means. - “infomap”: Uses the optional infomap package if installed. - “propagation”: Uses weighted label propagation.
Default is “louvain”.
- weightKeystr , optional
The edge dictionary key to use as edge weight. If set to None, each edge contributes a weight of 1 and duplicate undirected edges are aggregated by count. If set to “length”, “distance”, or “metric”, geometric edge length is used. If set to any other string, that edge dictionary value is used. Default is None.
- nClustersint , optional
Desired number of clusters for spectral clustering. If set to None, the number of clusters is estimated from the eigengap. This parameter is used only by algorithm=”spectral”. Default is None.
- maxIterationsint , optional
Maximum number of local iterations used by algorithm=”propagation” and by the k-means phase of algorithm=”spectral”. Ignored by the python-igraph Louvain implementation. Used by algorithm=”infomap” only if Infomap is unavailable and the method falls back to flow-weighted propagation. Default is 100.
- seedint , optional
Random seed used by order-sensitive algorithms and k-means initialisation. Default is 17.
- tolerancefloat , optional
Numerical tolerance used by spectral clustering and normalisation checks. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
The resulting community id list in active-vertex order.
- static Compare(graphA: TGraph, graphB: TGraph, weightAttributes: float = 0, weightStructure: float = 1, weightWeisfeilerLehman: float = 1, weightJaccard: float = 1, weightHopper: float = 0, wlKey: str = None, hopperKey: str = None, edgeWeightKey: str = None, iterations: int = 2, maxHops: int = 2, decay: float = 1.0, mantissa: int = 6, silent: bool = False, **kwargs) Optional[Dict[str, Any]]
Compares two TGraphs and returns a similarity or difference report.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’
The second input TGraph.
- weightAttributesfloat , optional
The input weight attributes value. Default is 0.
- weightStructurefloat , optional
The input weight structure value. Default is 1.
- weightWeisfeilerLehmanfloat , optional
The input weight weisfeiler lehman value. Default is 1.
- weightJaccardfloat , optional
The input weight jaccard value. Default is 1.
- weightHopperfloat , optional
The input weight hopper value. Default is 0.
- wlKeystr , optional
The dictionary key to use. Default is None.
- hopperKeystr , optional
The dictionary key to use. Default is None.
- edgeWeightKeystr , optional
The dictionary key to use. Default is None.
- iterationsint , optional
The input iterations value. Default is 2.
- maxHopsint , optional
The input max hops value. Default is 2.
- decayfloat , optional
The input decay value. Default is 1.0.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[Dict[str, Any]]
The resulting compare dictionary.
- static Compile(graph: TGraph, weightKey: str = 'weight', force: bool = False, useNumpy: bool = True, useSciPy: bool = True, useNumba: bool = False)
Prepare graph arrays, reusing bounded context entries when attached.
Without a context this preserves the existing compiled-cache behaviour. force=True clears the analysis context as well as rebuilding preparation.
- static CompileInfo(graph: TGraph) Dict[str, Any]
Returns a compact diagnostic report about the compiled cache.
- Parameters
- graphTGraph
The input TGraph.
- Returns
- dict
A dictionary reporting cache validity, version, size, and optional acceleration state.
- static CompiledAdjacency(graph: TGraph, mode: str = 'out', weightKey: str = 'weight') List[List[int]]
Returns a compiled adjacency array for the requested adjacency mode.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- weightKeystr , optional
The edge dictionary key to use as a weight. Default is ‘weight’.
- Returns
- List[List[int]]
The resulting compiled adjacency list.
- static Complement(graph: TGraph, ontology: bool = True, tolerance: float = 0.0001, silent: bool = False) Optional[TGraph]
Returns the complement graph of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. 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
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static Complete(graph: TGraph, ontology: bool = True, tolerance: float = 0.0001, silent: bool = False) Optional[TGraph]
Returns the complete graph on the active vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. 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
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static Connect(graph: TGraph, verticesA, verticesB, tolerance: float = 0.0001) Optional[TGraph]
Connects every vertex in verticesA to every vertex in verticesB with an edge.
- Parameters
- graphTGraph
The input TGraph.
- verticesAlist or single vertex
The first vertex set.
- verticesBlist or single vertex
The second vertex set.
- tolerancefloat , optional
Included for API compatibility. Default is 0.0001.
- Returns
- TGraph or None
The modified input TGraph, or None if invalid.
- static ConnectedComponents(graph, mode='all', *, key=None)
Return stable-index components; optionally annotate vertices and edges.
Component labels are one-based. Edges crossing distinct traversal groups receive zero (possible for directed out/in reachability partitions).
- static Connectivity(graph: TGraph, key: str = 'connectivity', colorKey: str = None, mode: str = 'all', normalize: bool = False, mantissa: int = 6, silent: bool = False, colorScale: str = 'viridis', *, weightKey=None)
Returns graph connectivity information for the input TGraph.
- Parameters
- graphTGraph
The input TGraph.
- keystr , optional
The dictionary key under which connectivity values are stored. Default is “connectivity”.
- colorKeystr , optional
The dictionary key under which computed colors are stored. Default is None.
- modestr , optional
The traversal mode. Valid values are “out”, “in”, and “all”. Default is “all”.
- normalizebool , optional
If set to True, values are normalized. Default is False.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- colorScalestr , optional
The color scale used when colorKey is not None. Default is “viridis”.
- Returns
- list
The resulting connectivity values.
- weightKey sums incident edge weights instead of counting edges. Missing values
- count as one. Existing normalization and annotation options apply to strengths.
- static ContainsEdge(graph: TGraph, edge: Any, tolerance: float = 0.0001, silent: bool = False) bool
Returns True if the input TGraph contains the input edge.
- Parameters
- graphTGraph
The input TGraph.
- edgeAny
The input edge, edge index, edge record, or pair of vertex indices/records.
- 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
- bool
True if the requested condition is satisfied. Otherwise, False.
- static ContainsVertex(graph: TGraph, vertex: Any, tolerance: float = 0.0001, silent: bool = False) bool
Returns True if the input TGraph contains the input vertex.
- Parameters
- graphTGraph
The input TGraph.
- vertexAny
The input vertex, vertex index, or vertex record.
- 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
- bool
True if the requested condition is satisfied. Otherwise, False.
- static ContractEdge(graph: TGraph, edge: Any, vertex: Any = None, tolerance: float = 0.0001, silent: bool = False) Optional[TGraph]
Contracts an edge by merging its endpoints into one replacement vertex.
- Parameters
- graphTGraph
The input TGraph.
- edgeint or dict
The edge, edge index, or edge record to contract.
- vertexAny , optional
Optional replacement vertex or vertex index. If omitted, a new midpoint vertex is created. 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
- TGraph or None
The modified input TGraph, or None if invalid.
- static Coordinates(graph: TGraph, vertex: Union[int, Dict[str, Any]], default: Optional[List[float]] = None) Optional[List[float]]
Returns the coordinates associated with a vertex of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- defaultOptional[List[float]] , optional
The default value to return when no valid value is found. Default is None.
- Returns
- list or None
The [x, y, z] coordinates of the input vertex, or the default value if unavailable.
- static Copy(graph: TGraph) Optional[TGraph]
Returns a copy of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static CutVertices(graph, *, key=None)
Return matching records; optionally annotate all active records with 1/0.
- static Degree(graph: TGraph, index: int, mode: str = 'all') int
Returns the degree of the input vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- indexint
The input index.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- Returns
- int
The resulting degree index or count.
- static DegreeCentrality(graph: TGraph, 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) Optional[List[float]]
Computes degree centrality for the input TGraph and stores the result in the dictionary of each vertex or edge.
This implementation keeps the richer DegreeCentrality API, but restores the fast compiled path used by the previous implementation for the common unweighted vertex-centrality case.
- Parameters
- graphTGraph
The input TGraph.
- weightKeystr , optional
If set to None, each edge contributes 1 to the degree. 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 dictionary is used as the edge weight. Default is None.
- normalizebool , optional
If nxCompatible is False, this controls whether values are min-max normalised between 0 and 1. Default is False.
- nxCompatiblebool , optional
If True, NetworkX-style degree centrality scaling is applied, i.e. degree / (n - 1). Default is True.
- useEdgesbool , optional
If True, degree centrality is calculated on the implicit line graph: each original edge becomes an entity and adjacent edges share a vertex. Default is False.
- edgeKeystr , optional
If not None and useEdges is True, edges are bundled by this dictionary key before normalisation. Default is None.
- keystr , optional
Dictionary key under which to store the calculated value. If None, values are returned but not stored. Default is “degree_centrality”.
- colorKeystr , optional
Dictionary key under which to store the colour value. If None, colours are not calculated or stored. For benchmarking against NetworkX, set this to None. Default is “dc_color”.
- colorScalestr , optional
Desired colour scale name. Default is “viridis”.
- mantissaint , optional
Number of decimal places. If None or negative, values are not rounded. Default is 6.
- tolerancefloat , optional
Tolerance used for normalisation and colour ranges. Default is 0.001.
- silentbool , optional
If True, error/warning messages are suppressed. Default is False.
- Returns
- list or None
The list of centrality values in vertex or edge order.
- static DegreeCentrality_old(graph: TGraph, mode: str = 'all', normalize: bool = True, key: str = 'degree_centrality', mantissa: int = 6) List[float]
Computes degree centrality values for the vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- normalizebool , optional
If set to True, returned values are normalized. Default is True.
- keystr , optional
The dictionary key to use. Default is ‘degree_centrality’.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- Returns
- List[float]
The resulting degree centrality list.
- static DegreeMatrix(graph: TGraph, mode: str = 'all') List[List[int]]
Returns the degree matrix of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- Returns
- List[List[int]]
The resulting degree matrix list.
- static DegreeSequence(graph: TGraph, mode: str = 'all') List[int]
Returns the degree sequence of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- Returns
- List[int]
The resulting degree sequence list.
- static Density(graph: TGraph, includeSelfLoops: bool = False) float
Returns the density of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- includeSelfLoopsbool , optional
If set to True, include self loops are included. Default is False.
- Returns
- float
The resulting density value.
- static Depth(graph: TGraph, vertex: Any, source: Any = None, mode: str = 'out', silent: bool = False) Optional[int]
Returns the traversal depth of vertices from a source vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexAny
The input vertex, vertex index, or vertex record.
- sourceAny , optional
The input source vertex, vertex index, or source identifier. Default is None.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[int]
The resulting depth index or count.
- static DepthFirstSearch(graph: TGraph, source: int, mode: str = 'out') List[int]
Returns the depth-first traversal order from the input source vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- sourceint
The input source vertex, vertex index, or source identifier.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- Returns
- List[int]
The resulting depth first search list.
- static DepthMap(graph: TGraph, source: Any = None, mode: str = 'out', key: str = 'depth', silent: bool = False, *, sources=None, method='single', distanceType='topological', weightKey=None, unreachable='ignore', radius=None)
Returns a dictionary mapping vertices to traversal depths.
- Parameters
- graph‘TGraph’
The input TGraph.
- sourceAny , optional
The input source vertex, vertex index, or source identifier. Default is None.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- keystr , optional
The dictionary key to use. Default is ‘depth’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Dict[int, int]
The resulting depth map dictionary.
- method=’single’ retains source traversal depths. method=’total’ sums distances
- from each selected source (sources=None selects all active vertices).
- distanceType=’metric’ uses geometric lengths; weightKey overrides distance costs.
- For total depth, unreachable=’ignore’ sums the reachable component, ‘infinity’
- returns infinity for disconnected sources, and ‘raise’ rejects them. radius is
- an inclusive distance cutoff. Return type remains a stable-index dictionary.
- static DetachVertex(graph: TGraph, *vertices, silent: bool = False) Optional[TGraph]
Removes all incident edges from the specified vertices while keeping the vertices active.
- Parameters
- graphTGraph
The input TGraph.
- *verticesint, dict, or list
Vertices, vertex indices, or vertex records to detach.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph or None
The modified input TGraph, or None if invalid.
- static Diameter(graph: TGraph, mode: str = 'all') Optional[int]
Returns the graph diameter of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- Returns
- Optional[int]
The resulting diameter index or count.
- static Dictionary(graph: TGraph) Dict[str, Any]
Returns the dictionary of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- dict
The graph dictionary.
- static Difference(graphA: TGraph, graphB: TGraph, silent: bool = False, *, vertexKeys=None, edgeKeys=None, tolerance=None, useCentroid=False, matchBy=None, ambiguous='separate')
Returns the graph difference between the first and second input TGraphs.
This implementation avoids unsafe index-based edge comparison. An edge in graphA is removed only if both of its endpoint vertices can be confidently matched to equivalent vertices in graphB and the corresponding edge exists in graphB.
- Parameters
- graphATGraph
The first input TGraph.
- graphBTGraph
The second input TGraph.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static DisjointPaths(graph: TGraph, source: Any, target: Any, disjoint: str = 'vertex', maxPaths: Optional[int] = None, optimize: bool = False, edgeKey: str = 'Length', vertexKey: str = '', snapEndpoints: bool = True, tolerance: float = 1e-12, silent: bool = False) List[List[int]]
Returns mutually disjoint paths between two vertices of the input TGraph.
The paths are computed jointly using network flow rather than by repeatedly removing previously discovered shortest paths.
Two disjointness modes are supported:
“vertex”: Paths may share the source and target but no internal vertices.
“edge”: Paths may share vertices but may not share an original TGraph
edge.
The primary objective is always to maximize the number of disjoint paths, subject to maxPaths.
If optimize is True, the secondary objective is to minimize the total cost of the complete maximum-cardinality path family. This is a joint optimization and is not equivalent to repeatedly finding the shortest remaining path.
Edge and vertex cost semantics follow TGraph.ShortestPath. Edge costs may be geometric length, unit hop cost, or values stored in an edge dictionary. Vertex costs are read from the specified vertex dictionary key. Source and target vertex costs are ignored.
- Parameters
- graphTGraph
The input TGraph.
- sourceAny
The source vertex. This may be a stable vertex index, TGraph vertex record, Topologic vertex, or coordinate-like input.
- targetAny
The target vertex. This may be a stable vertex index, TGraph vertex record, Topologic vertex, or coordinate-like input.
- disjointstr , optional
The disjointness criterion: “vertex” or “edge”. Common aliases are accepted. Default is “vertex”.
- maxPathsint , optional
Maximum number of paths to return. If None, the maximum possible number is computed. Default is None.
- optimizebool , optional
If True, minimizes the total cost of the maximum-cardinality path family. If False, returns any valid maximum-cardinality family. Default is False.
- edgeKeystr , optional
Edge cost key used when optimize=True. “Length”, “Distance”, “Metric”, “”, or None uses geometric endpoint distance. “hop”, “hops”, “unweighted”, or “unit” assigns unit cost. Other values refer to edge dictionary keys. Default is “Length”.
- vertexKeystr , optional
Numeric vertex dictionary key added as a traversal cost when optimize=True. Empty string disables vertex cost. Default is “”.
- snapEndpointsbool , optional
If True, unresolved source and target inputs are snapped to the nearest active TGraph vertices. Default is True.
- tolerancefloat , optional
Numerical flow tolerance. Default is 1e-12.
- silentbool , optional
If True, suppresses error and warning messages. Default is False.
- Returns
- List[List[int]]
The resulting mutually disjoint paths as ordered lists of stable TGraph vertex indices. Returns an empty list if no path exists or the input is invalid.
- static Distance(graph: TGraph, vertexA: Any, vertexB: Any, distanceType: str = 'topological', mode: str = 'out', mantissa: int = 6, silent: bool = False) Optional[float]
Returns the shortest-path distance between two vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexAAny
The first input vertex or vertex index.
- vertexBAny
The second input vertex or vertex index.
- distanceTypestr , optional
The input distance type value. Default is ‘topological’.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[float]
The resulting distance value.
- static Edge(graph: TGraph, index: Any = None, vertexA: Any = None, vertexB: Any = None, directed: Optional[bool] = None, silent: bool = False, copy: bool = False) Optional[Dict[str, Any]]
Returns an edge record from the input TGraph.
- Parameters
- graphTGraph
The input TGraph.
- indexAny , optional
The edge index or edge record. Default is None.
- vertexAAny , optional
The first vertex or vertex index. Default is None.
- vertexBAny , optional
The second vertex or vertex index. Default is None.
- directedbool , optional
If set to True, only a directed edge is considered. If set to False, only an undirected edge is considered. Default is None.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- copybool , optional
If set to True, a shallow copy of the record with a copied dictionary is returned. If set to False, the live internal record is returned and may be modified in-place. Default is False.
- Returns
- dict or None
The requested edge record.
- static EdgeBetween(graph: TGraph, src: int, dst: int, directed: Optional[bool] = None, copy: bool = False) Optional[Dict[str, Any]]
Returns the first active edge between two input vertex indices.
- Parameters
- graphTGraph
The input TGraph.
- srcint
The source vertex index.
- dstint
The destination vertex index.
- directedbool , optional
The direction flag used when searching for the edge. Default is None.
- copybool , optional
If set to True, a copy of the edge record is returned. If False, the live internal edge record is returned. Default is False.
- Returns
- dict or None
The requested edge record.
- static EdgeConnectivity(graph: TGraph, source: Any, target: Any, snapEndpoints: bool = True, tolerance: float = 1e-12, silent: bool = False) int
Returns the local edge connectivity between source and target.
This is the maximum number of source-target paths that do not share a physical graph edge. Paths may share intermediate vertices.
- Parameters
- graphTGraph
The input TGraph.
- sourceAny
The source vertex index or vertex-like input.
- targetAny
The target vertex index or vertex-like input.
- snapEndpointsbool , optional
If True, unresolved vertex-like inputs are snapped to the nearest active TGraph vertex. Default is True.
- tolerancefloat , optional
Numerical tolerance used by the maximum-flow calculation. Default is 1e-12.
- silentbool , optional
If True, suppresses error messages. Default is False.
- Returns
- int
The local edge connectivity. Returns 0 if the request is invalid or no source-target path exists.
- EdgeDictionary(index: Any, copy: bool = True) Dict[str, Any]
Returns the dictionary of an edge.
- Parameters
- indexint or dict
The edge index or edge record.
- copybool , optional
If set to True, a copy of the dictionary is returned. If set to False, the live dictionary is returned and may be modified in-place. Default is True.
- Returns
- dict
The edge dictionary.
- static EdgeIndex(graph: TGraph, edge: Union[int, Dict[str, Any]]) Optional[int]
Returns the index of the input edge.
- Parameters
- graph‘TGraph’
The input TGraph.
- edgeUnion[int, Dict[str, Any]]
The input edge, edge index, or edge record.
- Returns
- Optional[int]
The resulting edge index index or count.
- EdgeValue(edge: Any, key: str, default: Any = None) Any
Returns a dictionary value from an edge.
- Parameters
- edgeint or dict
The edge index or edge record.
- keystr
The dictionary key.
- defaultAny , optional
The value returned if the key is not found. Default is None.
- Returns
- Any
The requested value.
- static Edges(graph: TGraph, asTopologic: bool = False, useRepresentation: bool = True, active: bool = True, segmentCurves: bool = True, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False, selfLoopMode: str = 'circle', selfLoopRadius: float = 0.25, selfLoopMajorRadius: Optional[float] = None, selfLoopMinorRadius: Optional[float] = None, selfLoopSides: int = 32, selfLoopNormal: Optional[List[float]] = None, sagittaKey: str = 'sagitta', copy: bool = False, *, sortBy=None, reverse=False)
Returns the edges of the input TGraph.
- Parameters
- graphTGraph
The input TGraph.
- asTopologicbool , optional
If set to True, Topologic edge/wire representations are returned where possible. Default is False.
- useRepresentationbool , optional
If set to True, stored representation objects are used when possible. Default is True.
- activebool , optional
If set to True, only active records are returned. Default is True.
- segmentCurvesbool , optional
If set to True, curve control data may be converted to segmented wires. Default is True.
- mantissaint , optional
The number of decimal places to round numeric results 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.
- selfLoopModestr , optional
The self-loop geometry mode. Default is “circle”.
- selfLoopRadiusfloat , optional
The default self-loop radius. Default is 0.25.
- selfLoopMajorRadiusfloat , optional
The self-loop major radius. Default is None.
- selfLoopMinorRadiusfloat , optional
The self-loop minor radius. Default is None.
- selfLoopSidesint , optional
The number of self-loop segments. Default is 32.
- selfLoopNormallist , optional
The self-loop normal. Default is None.
- sagittaKeystr , optional
The dictionary key under which sagitta is stored. Default is “sagitta”.
- copybool , optional
When asTopologic is False, if set to True copied edge records are returned. If False, live edge records are returned. Default is False.
- Returns
- list
The requested edge records or Topologic representations.
- sortBy selects dictionary keys; reverse sorts descending. Missing values sort last.
- Record IDs and graph incidence remain unchanged.
- static EdgesBetween(graph: TGraph, src: int, dst: int, directed: Optional[bool] = None, copy: bool = False) List[Dict[str, Any]]
Returns all active edges between two input vertex indices.
- Parameters
- graphTGraph
The input TGraph.
- srcint
The source vertex index.
- dstint
The destination vertex index.
- directedbool , optional
The direction flag used when searching for edges. Default is None.
- copybool , optional
If set to True, copies of edge records are returned. If False, live internal records are returned. Default is False.
- Returns
- list
The matching edge records.
- static EdgesCSVString(graph: TGraph, includeInactive: bool = False) str
Returns a lightweight CSV string of TGraph edge records.
This method is intended for TGraph-native record serialisation. For PyTorch/PyG-ready datasets, use ByCSVPath and ExportToCSV.
- Parameters
- graphTGraph
The input TGraph.
- includeInactivebool , optional
If set to True, inactive edges are included. Default is False.
- Returns
- str
The edges CSV string.
- static EigenVectorCentrality(graph: TGraph, 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) List[float]
Computes eigenvector centrality values for the vertices of the input TGraph.
- Parameters
- graphTGraph
The input TGraph.
- normalizebool , optional
If set to True, returned values are normalized. Default is False.
- keystr , optional
The dictionary key under which values are stored. Default is “eigen_vector_centrality”.
- colorKeystr , optional
The dictionary key under which computed colors are stored. Default is “evc_color”.
- colorScalestr , optional
The color scale used to generate colors. Default is “viridis”.
- mantissaint , optional
The number of decimal places to round numeric results 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 resulting eigenvector centrality values.
- static EigenvectorCentrality(graph: TGraph, mode: str = 'out', iterations: int = 100, tolerance: float = 1e-09, key: str = 'eigenvector_centrality', mantissa: int = 6) List[float]
Computes eigenvector centrality values for the vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- iterationsint , optional
The input iterations value. Default is 100.
- tolerancefloat , optional
The desired tolerance. Default is 1e-09.
- keystr , optional
The dictionary key to use. Default is ‘eigenvector_centrality’.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- Returns
- List[float]
The resulting eigenvector centrality list.
- static EnsureCompiled(graph: TGraph, weightKey: str = 'weight', force: bool = False, useNumpy: bool = True, useSciPy: bool = True, useNumba: bool = False) Optional[Dict[str, Any]]
Returns a valid compiled cache for the input TGraph, compiling it if needed.
- Parameters
- graphTGraph
The input TGraph.
- weightKeystr , optional
The edge dictionary key to use as a weight. Default is “weight”.
- forcebool , optional
If set to True, the cache is rebuilt even if it appears valid. Default is False.
- useNumpybool , optional
If set to True, NumPy acceleration arrays are created when available. Default is True.
- useSciPybool , optional
If set to True, SciPy sparse matrices are created when available. Default is True.
- useNumbabool , optional
If set to True, the compiled cache records that Numba acceleration was requested. Default is False.
- Returns
- dict or None
The compiled cache dictionary, or None if the input is invalid.
- static ExplainInference(graph: TGraph, triple=None, subject=None, predicate=None, object=None, result=None, silent: bool = False, **kwargs)
Explains an asserted or inferred semantic fact for the TGraph.
- static ExportGraphToCSV(graph: TGraph, *args, **kwargs)
Deprecated compatibility alias for TGraph.ExportToCSV.
Use TGraph.ExportToCSV instead.
- Parameters
- graphTGraph
The input TGraph.
- Returns
- bool or None
True if successful; otherwise None.
- static ExportGraphsToCSV(*args, **kwargs)
Deprecated compatibility alias for TGraph.ExportToCSV.
Use TGraph.ExportToCSV instead. ExportToCSV accepts either one TGraph or a list of TGraphs.
- Returns
- bool or None
True if successful; otherwise None.
- static ExportJSONLD(graph: TGraph, path: str, indent: Optional[int] = 2, silent: bool = False, **kwargs) Optional[str]
Exports the input TGraph to a JSON-LD file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr
The input file path, folder path, or sequence of vertex indices, depending on context.
- indentOptional[int] , optional
The input indent value. Default is 2.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting export jsonld string.
- static ExportTTL(graph: TGraph, path: str, silent: bool = False, **kwargs) Optional[str]
Exports the input TGraph to a TTL file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr
The input file path, folder path, or sequence of vertex indices, depending on context.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting export ttl string.
- static ExportToAdjacencyMatrixCSV(adjacencyMatrix: List[List[Any]], path: str) Optional[str]
Exports an adjacency matrix to a CSV file.
- Parameters
- adjacencyMatrixlist
The adjacency matrix.
- pathstr
The output CSV path.
- Returns
- str or None
The output path if successful; otherwise None.
- static ExportToBOT(graph: TGraph, path: str, overwrite: bool = False, silent: bool = False, **kwargs) Optional[str]
Exports the input TGraph to a BOT-compatible TTL file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr
The input file path, folder path, or sequence of vertex indices, depending on context.
- overwritebool , optional
The input overwrite value. Default is False.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting export to bot string.
- static ExportToCSV(graph, path, graphLabelKey: str = 'label', defaultGraphLabel=0, graphFeaturesKeys: list = None, graphIDHeader: str = 'graph_id', graphLabelHeader: str = 'label', graphFeaturesHeader: str = 'feat', edgeLabelKey: str = 'label', defaultEdgeLabel=0, edgeFeaturesKeys: list = None, edgeSRCHeader: str = 'src_id', edgeDSTHeader: str = 'dst_id', edgeLabelHeader: str = 'label', edgeFeaturesHeader: str = 'feat', edgeTrainMaskHeader: str = 'train_mask', edgeValidateMaskHeader: str = 'val_mask', edgeTestMaskHeader: str = 'test_mask', edgeMaskKey: str = 'mask', edgeTrainRatio: float = 0.8, edgeValidateRatio: float = 0.1, edgeTestRatio: float = 0.1, bidirectional: bool = True, nodeLabelKey: str = 'label', defaultNodeLabel=0, nodeFeaturesKeys: list = None, nodeIDHeader: str = 'node_id', nodeLabelHeader: str = 'label', nodeFeaturesHeader: str = 'feat', nodeTrainMaskHeader: str = 'train_mask', nodeValidateMaskHeader: str = 'val_mask', nodeTestMaskHeader: str = 'test_mask', nodeMaskKey: str = 'mask', nodeTrainRatio: float = 0.8, nodeValidateRatio: float = 0.1, nodeTestRatio: float = 0.1, nodeXHeader: str = 'x', nodeYHeader: str = 'y', nodeZHeader: str = 'z', mantissa: int = 6, overwrite: bool = False, silent: bool = False) Optional[bool]
Exports one TGraph or a list of TGraphs to a PyTorch/PyG-ready CSV folder.
This is the public CSV export method. It accepts either a single TGraph or a list of TGraphs and writes graphs.csv, nodes.csv, edges.csv, and meta.yaml.
- Parameters
- graphTGraph or list
The input TGraph or list of TGraphs.
- pathstr
The output folder path.
- graphLabelKeystr , optional
Graph dictionary key for graph labels. Default is “label”.
- defaultGraphLabelAny , optional
Default graph label. Default is 0.
- graphFeaturesKeyslist , optional
Graph feature dictionary keys. Default is None.
- graphIDHeaderstr , optional
Graph ID header. Default is “graph_id”.
- graphLabelHeaderstr , optional
Graph label header. Default is “label”.
- graphFeaturesHeaderstr , optional
Graph feature prefix. Default is “feat”.
- edgeLabelKeystr , optional
Edge dictionary key for edge labels. Default is “label”.
- defaultEdgeLabelAny , optional
Default edge label. Default is 0.
- edgeFeaturesKeyslist , optional
Edge feature dictionary keys. Default is None.
- 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”.
- edgeFeaturesHeaderstr , optional
Edge feature prefix. Default is “feat”.
- edgeTrainMaskHeaderstr , optional
Edge train mask header. Default is “train_mask”.
- edgeValidateMaskHeaderstr , optional
Edge validation mask header. Default is “val_mask”.
- edgeTestMaskHeaderstr , optional
Edge test mask header. Default is “test_mask”.
- edgeMaskKeystr , optional
Edge dictionary key for split assignment. Values 0, 1, 2 mean train, validation, and test respectively. Default is “mask”.
- edgeTrainRatiofloat , optional
Edge train ratio. Default is 0.8.
- edgeValidateRatiofloat , optional
Edge validation ratio. Default is 0.1.
- edgeTestRatiofloat , optional
Edge test ratio. Default is 0.1.
- bidirectionalbool , optional
If set to True, writes both source-to-destination and destination-to-source rows for each non-self-loop edge. Default is True.
- nodeLabelKeystr , optional
Vertex dictionary key for node labels. Default is “label”.
- defaultNodeLabelAny , optional
Default node label. Default is 0.
- nodeFeaturesKeyslist , optional
Vertex feature dictionary keys. Default is None.
- nodeIDHeaderstr , optional
Node ID header. Default is “node_id”.
- nodeLabelHeaderstr , optional
Node label header. Default is “label”.
- nodeFeaturesHeaderstr , optional
Node feature prefix. Default is “feat”.
- nodeTrainMaskHeaderstr , optional
Node train mask header. Default is “train_mask”.
- nodeValidateMaskHeaderstr , optional
Node validation mask header. Default is “val_mask”.
- nodeTestMaskHeaderstr , optional
Node test mask header. Default is “test_mask”.
- nodeMaskKeystr , optional
Vertex dictionary key for split assignment. Values 0, 1, 2 mean train, validation, and test respectively. Default is “mask”.
- nodeTrainRatiofloat , optional
Node train ratio. Default is 0.8.
- nodeValidateRatiofloat , optional
Node validation ratio. Default is 0.1.
- nodeTestRatiofloat , optional
Node test ratio. Default is 0.1.
- nodeXHeaderstr , optional
Node X-coordinate header. Default is “x”.
- nodeYHeaderstr , optional
Node Y-coordinate header. Default is “y”.
- nodeZHeaderstr , optional
Node Z-coordinate header. Default is “z”.
- mantissaint , optional
The desired number of decimal places. Default is 6.
- overwritebool , optional
If set to True, existing CSV files are overwritten. Default is False.
- silentbool , optional
If set to True, errors and warnings are suppressed. Default is False.
- Returns
- bool or None
True if successful; otherwise None.
- static ExportToGEXF(graph: TGraph, 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) Optional[str]
Exports the input TGraph to a GEXF file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr , optional
The input file path, folder path, or sequence of vertex indices, depending on context. Default is None.
- graphWidthfloat , optional
The input graph width value. Default is 20.
- graphLengthfloat , optional
The input graph length value. Default is 20.
- graphHeightfloat , optional
The input graph height value. Default is 20.
- defaultVertexColorstr , optional
The color value to use. Default is ‘black’.
- defaultVertexSizefloat , optional
The input default vertex size value. Default is 3.
- vertexLabelKeystr , optional
The dictionary key to use. Default is None.
- vertexColorKeystr , optional
The dictionary key to use. Default is None.
- vertexSizeKeystr , optional
The dictionary key to use. Default is None.
- defaultEdgeColorstr , optional
The color value to use. Default is ‘black’.
- defaultEdgeWeightfloat , optional
The input default edge weight value. Default is 1.
- defaultEdgeTypestr , optional
The input default edge type value. Default is ‘undirected’.
- edgeLabelKeystr , optional
The dictionary key to use. Default is None.
- edgeColorKeystr , optional
The dictionary key to use. Default is None.
- edgeWeightKeystr , optional
The dictionary key to use. Default is None.
- overwritebool , optional
The input overwrite value. Default is False.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- Returns
- Optional[str]
The resulting export to gexf string.
- static ExportToGraphVizGraph(graph: TGraph, path: str, overwrite: bool = False, silent: bool = False, **kwargs) Optional[str]
Exports the input TGraph to a GraphViz graph object or file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr
The input file path, folder path, or sequence of vertex indices, depending on context.
- overwritebool , optional
The input overwrite value. Default is False.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting export to graph viz graph string.
- static ExportToJSON(graph: TGraph, path: str, propertiesKey: str = 'properties', verticesKey: str = 'vertices', edgesKey: str = 'edges', vertexLabelKey: str = '', edgeLabelKey: str = '', xKey: str = 'x', yKey: str = 'y', zKey: str = 'z', indent: int = 4, sortKeys: bool = False, mantissa: int = 6, overwrite: bool = False) Optional[str]
Exports the input TGraph to a JSON file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr
The input file path, folder path, or sequence of vertex indices, depending on context.
- propertiesKeystr , optional
The dictionary key to use. Default is ‘properties’.
- verticesKeystr , optional
The dictionary key to use. Default is ‘vertices’.
- edgesKeystr , optional
The dictionary key to use. Default is ‘edges’.
- vertexLabelKeystr , optional
The dictionary key to use. Default is ‘’.
- edgeLabelKeystr , optional
The dictionary key to use. Default is ‘’.
- xKeystr , optional
The dictionary key to use. Default is ‘x’.
- yKeystr , optional
The dictionary key to use. Default is ‘y’.
- zKeystr , optional
The dictionary key to use. Default is ‘z’.
- indentint , optional
The input indent value. Default is 4.
- sortKeysbool , optional
The input sort keys value. Default is False.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- overwritebool , optional
The input overwrite value. Default is False.
- Returns
- Optional[str]
The resulting export to json string.
- static ExportToJSONLD(graph: TGraph, path: str, indent: int = 2, sortKeys: bool = False, overwrite: bool = False, silent: bool = False, **kwargs) Optional[str]
Exports the input TGraph to a JSON-LD file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr
The input file path, folder path, or sequence of vertex indices, depending on context.
- indentint , optional
The input indent value. Default is 2.
- sortKeysbool , optional
The input sort keys value. Default is False.
- overwritebool , optional
The input overwrite value. Default is False.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting export to jsonld string.
- static ExportToRDF(graph: TGraph, path: str, overwrite: bool = True, silent: bool = False, **kwargs) Optional[str]
Exports the input TGraph to an RDF/Turtle file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr
The input file path, folder path, or sequence of vertex indices, depending on context.
- overwritebool , optional
The input overwrite value. Default is True.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting export to rdf string.
- static ExportToWiki(graph: TGraph, path: str, overwrite: bool = True, silent: bool = False, **kwargs) Optional[str]
Exports the input TGraph to a Wiki-compatible text file.
- Parameters
- graph‘TGraph’
The input TGraph.
- pathstr
The input file path, folder path, or sequence of vertex indices, depending on context.
- overwritebool , optional
The input overwrite value. Default is True.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting export to wiki string.
- static FiedlerVector(graph: TGraph, mantissa: int = 6, silent: bool = False) List[float]
Returns the Fiedler vector of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- List[float]
The resulting fiedler vector list.
- static FiedlerVectorPartition(graph: TGraph, key: str = 'partition', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False) List[int]
Partitions the input TGraph using the Fiedler vector.
- Parameters
- graph‘TGraph’
The input TGraph.
- keystr , optional
The dictionary key to use. Default is ‘partition’.
- mantissaint , optional
The number of decimal places to round numeric results 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[int]
The resulting fiedler vector partition list.
- static Figure(graph: TGraph, title: str = None, width: int = None, height: int = None, showVertexLabels: bool = False, showEdgeLabels: bool = False, backgroundColor: str = 'white', silent: bool = False, **kwargs)
Returns a Plotly figure representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- titlestr , optional
The optional figure title. Default is None.
- widthint , optional
The figure or output width. Default is None.
- heightint , optional
The figure or output height. Default is None.
- showVertexLabelsbool , optional
If set to True, show vertex labels are shown. Default is False.
- showEdgeLabelsbool , optional
If set to True, show edge labels are shown. Default is False.
- backgroundColorstr , optional
The color value to use. Default is ‘white’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Any
The resulting figure object or value.
- static FromPython(data: Dict[str, Any], ontology: bool = True) Optional[TGraph]
Creates a TGraph from a Python data dictionary.
- Parameters
- dataDict[str, Any]
The input data dictionary.
- ontologybool , optional
If set to True, ontology metadata is added or preserved where applicable. Default is True.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static GlobalClusteringCoefficient(graph: TGraph, mantissa: int = 6, silent: bool = False) float
Returns the global clustering coefficient of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- float
The resulting global clustering coefficient value.
- static GraphVizGraph(graph, directed=None, rankDir='TB', showVertexLabel=True, vertexLabelKey='label', showEdgeLabel=False, edgeLabelKey='label', *, layout='dot', graphAttributes=None, vertexAttributes=None, edgeAttributes=None, graphAttributeKeys=None, vertexAttributeKeys=None, edgeAttributeKeys=None, asObject=False, bgColor=None, fontName=None, fontSize=None, splines=None, vertexShape=None, vertexShapeKey=None, vertexFillColor=None, vertexFillColorKey=None, vertexColor=None, vertexColorKey=None, vertexWidth=None, vertexWidthKey=None, vertexHeight=None, vertexHeightKey=None, vertexFixedSize=None, vertexStyle=None, edgeColor=None, edgeColorKey=None, edgeWidth=None, edgeWidthKey=None, edgeStyle=None, edgeStyleKey=None, showGraphLabel=False, graphLabel='', graphLabelKey=None)
Return styled DOT text, or a graphviz.Source with asObject=True.
*Attributes dictionaries map DOT attribute names to constant values. *AttributeKeys map DOT names to graph/vertex/edge dictionary keys, which override constants where present. Convenience styling options follow the same rule. Layout is stored in DOT and selects the optional object’s engine. DOT generation requires no Graphviz package; no rendering or file writing occurs. asObject needs the optional graphviz Python package.
- static Guid(graph: TGraph) Optional[str]
Returns a persistent GUID for the input TGraph, creating one if needed.
- Parameters
- graphTGraph
The input TGraph.
- Returns
- str or None
The graph GUID, or None if the input is invalid.
- static HasEdge(graph: TGraph, srcIndex: int, dstIndex: int, directed: Optional[bool] = None) bool
Returns True if an edge exists between two input vertex indices.
- Parameters
- graph‘TGraph’
The input TGraph.
- srcIndexint
The source vertex index.
- dstIndexint
The destination vertex index.
- directedOptional[bool] , optional
If set to True, graph edges are treated as directed. Default is None.
- Returns
- bool
True if the requested condition is satisfied. Otherwise, False.
- 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) Optional[TGraph]
Creates a Hasse diagram TGraph for the subtopologies of an input topology.
- Parameters
- topologytopologic_core.Topology
The input topology.
- typeslist , optional
Subtopology types to include. Default is vertex, edge, wire, face, shell, cell, and cellComplex.
- topDownbool , optional
If set to True, edges point from higher-dimensional topologies to lower- dimensional topologies. Default is False.
- minDistancefloat , optional
Used as the vertical spacing between ranks in generated coordinates. Default is 0.1.
- vertexLabelKeystr , optional
Dictionary key for node labels. Default is “label”.
- vertexTypeKeystr , optional
Dictionary key for topology type. Default is “type”.
- vertexColorKeystr , optional
Dictionary key for colour. Default is “color”.
- colorScalestr , optional
Colour scale name. Default is “viridis”.
- storeBREPbool , optional
If set to True, stores BREP strings where available. 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
- TGraph or None
The Hasse diagram as a TGraph.
- static HopperKernel(graphA: TGraph, graphB: TGraph, key: str = None, maxHops: int = 2, hop: int = None, labelKey: str = None, decay: float = 1.0, normalize: bool = True, mantissa: int = 6, silent: bool = False) Optional[float]
Returns a graph kernel similarity based on hop features.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’
The second input TGraph.
- keystr , optional
The dictionary key to use. Default is None.
- maxHopsint , optional
The input max hops value. Default is 2.
- hopint , optional
The input hop value. Default is None.
- labelKeystr , optional
The dictionary key to use. Default is None.
- decayfloat , optional
The input decay value. Default is 1.0.
- normalizebool , optional
If set to True, returned values are normalized. Default is True.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[float]
The resulting hopper kernel value.
- static Impose(graphA, graphB, silent=False, *, vertexKeys=None, edgeKeys=None, matchBy=None, tolerance=1e-06, useCentroid=False, ambiguous='separate')
Combine both graphs, letting B overwrite matching attributes.
Matching is one-to-one across inputs. Supply vertexKeys for semantic identity or matchBy=’coordinates’ and tolerance for geometry. Ambiguities stay separate unless ambiguous=’error’. Inputs are not modified.
- static Imprint(graphA, graphB, silent=False, *, vertexKeys=None, edgeKeys=None, matchBy=None, tolerance=1e-06, useCentroid=False, ambiguous='separate')
Keep A’s structure and overwrite matching attributes from B.
No B-only vertex or edge is added. A’s coordinates are retained unless useCentroid=True. Matching options follow Impose.
- static IncidentEdges(graph: TGraph, index: int, mode: str = 'all') List[Dict[str, Any]]
Returns the active edges incident to the input vertex index.
- Parameters
- graph‘TGraph’
The input TGraph.
- indexint
The input index.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- Returns
- List[Dict[str, Any]]
The resulting incident edges list.
- static IncomingEdges(graph: TGraph, vertex: Union[int, Dict[str, Any]]) List[Dict[str, Any]]
Returns the incoming edges of the input vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- Returns
- List[Dict[str, Any]]
The resulting incoming edges list.
- static IncomingVertices(graph: TGraph, vertex: Union[int, Dict[str, Any]]) List[Dict[str, Any]]
Returns the incoming adjacent vertices of the input vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- Returns
- List[Dict[str, Any]]
The resulting incoming vertices list.
- static InducedSubgraph(graph: TGraph, vertices: Iterable[Any], silent: bool = False) Optional[TGraph]
Returns the induced subgraph on the input vertex indices.
- Parameters
- graph‘TGraph’
The input TGraph.
- verticesIterable[Any]
The input vertices or vertex indices.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static InferOntology(graph: TGraph, profile: str = 'rdfs', includeOntologyAxioms: bool = True, includeBOT: bool = True, applyToGraph: bool = False, returnResult: bool = False, inplace: bool = False, maxIterations: int = 64, namespacePrefix: str = 'inst', silent: bool = False, **kwargs)
Runs ontology inference for the input TGraph.
- static Integration(graph: TGraph, normalize: bool = True, key: str = 'integration', mantissa: int = 6, silent: bool = False, radius: Optional[float] = None, method: str = 'closeness', colorKey: str = 'cc_color', colorScale: str = 'viridis', *, weightKey=None, distanceType='topological', mode='out', nxCompatible=True)
Compute closeness-based or Depthmap Hillier-Hanson integration.
- Parameters
- graphTGraph
The input graph. Depthmap mode uses its simple undirected active adjacency, ignoring self-loops, parallel edges and edge weights.
- normalizebool , optional
Normalize closeness values. Applies only to method=’closeness’. Depthmap mode always returns intrinsic HH normalization, not a further min-max rescaling. Default is True.
- keystr , optional
Vertex dictionary result key. None disables storage.
- mantissaint , optional
Decimal precision. None or a negative value disables rounding.
- silentbool , optional
Suppress diagnostics.
- radiusfloat , optional
Inclusive hop cutoff. None means the entire reachable component.
- methodstr , optional
‘closeness’ preserves the existing default. ‘depthmap’ or ‘hh’ computes Integration [HH]: D(n)/RA, with n including the source, MD=total_depth/(n-1), RA=2*(MD-1)/(n-2), and D(n)=2*(n*(log2((n+2)/3)-1)+1)/((n-1)*(n-2)). Names are case-insensitive. This is topological HH integration, not angular segment integration or NAIN.
- colorKeystr , optional
Vertex colour key; None disables colour storage. Default cc_color preserves existing closeness behaviour. Undefined HH values are grey.
- colorScalestr , optional
Colour scale, including ‘syntax’. Valid HH values set the colour range.
- Returns
- list or None
Results in active-vertex order. HH is -1 when n<=2 or MD<=1, matching Depthmap’s undefined-value convention. Invalid inputs return None. Empty graphs return [].
Notes
References: DepthmapX salalib/axialmodules/axialintegration.cpp and genlib/pafmath.h. Traversal uses O(V+E) memory and O(V*(V+E)) time globally; a local radius can reduce the visited neighbourhoods. Unweighted distances use SciPy sparse traversal in bounded source batches when available, preserving the same cutoffs and reached-node counts. Small graphs and unavailable acceleration use Python traversal.
- static Intersect(graphA: TGraph, graphB: TGraph, silent: bool = False, *, vertexKeys=None, edgeKeys=None, tolerance=None, useCentroid=False, matchBy=None, ambiguous='separate')
Returns the graph intersection of two input TGraphs.
This implementation avoids unsafe index-based vertex and edge comparison. Vertices are considered common only when they can be confidently matched by a stable identity key. Edges are considered common only when both endpoint vertices match and the corresponding edge exists in graphB.
- Parameters
- graphATGraph
The first input TGraph.
- graphBTGraph
The second input TGraph.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static InvalidateCache(graph: TGraph) Optional[TGraph]
Invalidates the compiled cache of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static IsBipartite(graph: TGraph) bool
Returns True if the input TGraph is bipartite.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- bool
True if the requested condition is satisfied. Otherwise, False.
- static IsCompiled(graph: TGraph, weightKey: str = None) bool
Returns True if the input TGraph has a valid compiled cache.
- Parameters
- graphTGraph
The input TGraph.
- weightKeystr , optional
If specified, the compiled cache must also match this edge weight key. If set to None, only the graph version is checked. Default is None.
- Returns
- bool
True if the graph has a valid compiled cache; otherwise False.
- static IsComplete(graph: TGraph, includeSelfLoops: bool = False) bool
Returns True if the input TGraph is complete.
- Parameters
- graph‘TGraph’
The input TGraph.
- includeSelfLoopsbool , optional
If set to True, include self loops are included. Default is False.
- Returns
- bool
True if the requested condition is satisfied. Otherwise, False.
- static IsConnected(graph: TGraph, mode: str = 'all') bool
Returns True if the input TGraph is connected.
This implementation traverses TGraph’s native incidence tables directly and deliberately avoids TGraph.Compile(). It also avoids constructing the complete connected-components list when only a Boolean result is required.
- Parameters
- graphTGraph
The input TGraph.
- modestr, optional
The traversal or adjacency mode.
“all”: edges are traversed in either direction.
“in”: directed edges are traversed toward their source; undirected
edges remain bidirectional. - Any other value, including “out”: directed edges are traversed from source to destination; undirected edges remain bidirectional.
Default is “all”.
- Returns
- bool
True if all active vertices are reachable from the first active vertex under the requested traversal mode. Otherwise, False.
Notes
As with the previous implementation, an empty graph and a graph containing one active vertex are considered connected.
- static IsDirected(graph: TGraph) bool
Returns True if the input TGraph is directed.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- bool
True if the input TGraph is directed. Otherwise, False.
- static IsEmpty(graph: TGraph) bool
Returns True if the input TGraph has no active vertices or edges.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- bool
True if the requested condition is satisfied. Otherwise, False.
- static IsErdoesGallai(sequence: Any, silent: bool = False) bool
Returns True if the input degree sequence satisfies the Erdős-Gallai theorem.
- Parameters
- sequenceAny
The input sequence value.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- bool
True if the requested condition is satisfied. Otherwise, False.
- static IsInstance(graph: Any) bool
Returns True if the input object is a TGraph.
- Parameters
- graphAny
The input TGraph.
- Returns
- bool
True if the input object is a TGraph. Otherwise, False.
- static IsIsomorphic(graphA: TGraph, graphB: TGraph, vertexIDKey: str = None, edgeWeightKey: str = None, wlKey: str = None, iterations: int = 2, silent: bool = False) bool
Returns True if two input TGraphs are isomorphic under the requested constraints.
The check is exact. Weisfeiler-Lehman refinement is used only to reduce candidate domains before exhaustive backtracking; it cannot by itself make a non-exact match succeed.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’
The second input TGraph.
- vertexIDKeystr , optional
Optional vertex dictionary key whose values must be preserved by the isomorphism. Default is None.
- edgeWeightKeystr , optional
Optional edge dictionary key whose values must be preserved by the isomorphism. Default is None.
- wlKeystr , optional
Optional vertex dictionary key used as the initial Weisfeiler-Lehman label. When supplied, its values are preserved by the isomorphism. Default is None.
- iterationsint , optional
Number of Weisfeiler-Lehman refinement iterations. Default is 2.
- silentbool , optional
Retained for API compatibility. Default is False.
- Returns
- bool
True if the graphs are isomorphic under the requested constraints; otherwise False.
- static IsTree(graph: TGraph) bool
Returns True if the input TGraph is a tree.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- bool
True if the requested condition is satisfied. Otherwise, False.
- static IsolatedVertices(graph: TGraph) List[Dict[str, Any]]
Returns the isolated vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- List[Dict[str, Any]]
The resulting isolated vertices list.
- static IsovistIntersectionGraph(isovists=None, origins=None, minOverlap: float = 0.0, tolerance: float = 0.0001, silent: bool = False, computeOverlap: bool = True, batchSize: int = 256, workers: Optional[int] = None, radius: Optional[float] = None, radiusSides: int = 64, face=None, obstacles=None)
Construct an undirected graph of shared visible areas.
- Parameters
- isovistsiterable or Face
Coplanar, straight-sided Topologic Faces (holes supported), closed Wires, or Shapely Polygon/MultiPolygon objects. Shapely inputs must be strictly 2D and cannot be mixed with Topologic inputs. Each input retains its own node, including duplicates and isolated isovists. Alternatively supply a host Face here (or through face=) to generate one isovist per origin using Face.Isovist.
- originsiterable, optional
One Topologic Vertex or finite xyz coordinate per isovist. If absent, use an interior representative point; this is not the generating viewpoint. Topologic isovists remain linked as node originators.
- minOverlapfloat, optional
Strict minimum intersection area, in squared model units. Default 0. Boundary-only contact never creates a link.
- tolerancefloat, optional
Positive distance tolerance for coplanarity, not an area threshold. Coordinates are not snapped, buffered, or rounded.
- silentbool, optional
Suppress error messages. Invalid input returns None.
- computeOverlapbool, optional
Default True stores overlap_area, overlap_jaccard, overlap_fraction_src, overlap_fraction_dst on edges. False with minOverlap=0 uses an interior-intersection predicate without creating intersection geometry. Positive minOverlap still requires areas.
- batchSizeint, optional
Maximum query isovists per batch (default 256); candidate memory is O(batchSize*n), rather than a full n*n pair matrix.
- workersint, optional
None uses up to eight available CPU threads for large candidate batches. Set 1 to disable threading, or choose a positive count. Only compiled geometry operations run in workers; graph mutation stays serial. Small batches avoid thread dispatch overhead.
- radiusfloat, optional
Finite maximum visibility distance in model units, greater than tolerance. Forwarded to Face.Isovist for generated isovists. Existing isovists are clipped to the same inscribed radius polygon first. Explicit origins are required whenever radius is supplied. A SciPy cKDTree limits candidate centres to 2*radius (with a conservative tolerance margin), then bounding boxes and exact geometry decide connections. None preserves unlimited visibility and STRtree search.
- radiusSidesint, optional
Inscribed circle approximation, forwarded to Face.Isovist; default 64, integer >=8. Used for clipping precomputed isovists too.
- faceFace, optional
Host face for generating isovists from origins. Supply either face or isovists, not both. Origins may be Vertices or xyz coordinates.
- obstaclesiterable of Wire, optional
Additional obstacles forwarded to Face.Isovist in generation mode. Not accepted with precomputed isovists, which already encode blockers.
- Returns
- TGraph or None
Logical edges without costly Topologic Edge/boolean construction. Node dictionaries include x/y/z and isovist_area. Edge order is deterministic. Graph construction uses Shapely >=2, packed STRtree bounding-box pruning and compiled vectorized GEOS operations. Dense output necessarily costs O(n*n). Invalid polygons are rejected, never silently repaired. Curved boundaries must be tessellated first.
- static JSONData(graph: TGraph, includeRepresentations: bool = False) Dict[str, Any]
Returns a JSON-compatible data dictionary representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- includeRepresentationsbool , optional
If set to True, stored representation objects are included in the output. Default is False.
- Returns
- Dict[str, Any]
The resulting jsondata dictionary.
- static JSONDataGraphCompatible(graph: TGraph, propertiesKey: str = 'properties', verticesKey: str = 'vertices', edgesKey: str = 'edges', xKey: str = 'x', yKey: str = 'y', zKey: str = 'z', mantissa: int = 6) Dict[str, Any]
Returns graph-compatible JSON data representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- propertiesKeystr , optional
The dictionary key to use. Default is ‘properties’.
- verticesKeystr , optional
The dictionary key to use. Default is ‘vertices’.
- edgesKeystr , optional
The dictionary key to use. Default is ‘edges’.
- xKeystr , optional
The dictionary key to use. Default is ‘x’.
- yKeystr , optional
The dictionary key to use. Default is ‘y’.
- zKeystr , optional
The dictionary key to use. Default is ‘z’.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- Returns
- Dict[str, Any]
The resulting jsondata graph compatible dictionary.
- static JSONLDData(graph: TGraph, includeVertices: bool = True, includeEdges: bool = True, includeDictionaries: bool = True, includeBOT: bool = True, namespacePrefix: str = 'inst', instanceNamespace: str = 'http://w3id.org/topologicpy/instance#') Dict[str, Any]
Returns JSON-LD data representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- includeVerticesbool , optional
If set to True, include vertices are included. Default is True.
- includeEdgesbool , optional
If set to True, include edges are included. Default is True.
- includeDictionariesbool , optional
If set to True, dictionaries are included in the output. Default is True.
- includeBOTbool , optional
If set to True, include bot are included. Default is True.
- namespacePrefixstr , optional
The input namespace prefix value. Default is ‘inst’.
- instanceNamespacestr , optional
The input instance namespace value. Default is ‘http://w3id.org/topologicpy/instance#’.
- Returns
- Dict[str, Any]
The resulting jsonlddata dictionary.
- static JSONLDString(graph: TGraph, indent: Optional[int] = 2, **kwargs) str
Returns a JSON-LD string representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- indentOptional[int] , optional
The input indent value. Default is 2.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- str
The resulting jsonldstring string.
- static JSONString(graph: TGraph, indent: Optional[int] = None, includeRepresentations: bool = False) str
Returns a JSON string representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- indentOptional[int] , optional
The input indent value. Default is None.
- includeRepresentationsbool , optional
If set to True, stored representation objects are included in the output. Default is False.
- Returns
- str
The resulting jsonstring string.
- static KHopsSubgraph(graph: TGraph, vertices: list, k: int = 1, direction: str = 'both', silent: bool = False) Optional[TGraph]
Returns the induced subgraph of vertices within k hops of the input vertices.
- Parameters
- graphTGraph
The input TGraph.
- verticeslist
Starting vertices, vertex indices, or vertex records.
- kint , optional
Maximum hop distance from the starting vertices. Default is 1.
- directionstr , optional
Traversal direction: “in”, “out”, or “both”. Default is “both”.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph or None
The resulting induced TGraph subgraph.
- static KShortestPaths(graph, source, target, k=10, mode='out', edgeKey='Length', vertexKey=None, edgeFilter=None, vertexFilter=None, edgeCostFunc=None, vertexCostFunc=None, timeLimit=None, returnVertices=False, returnEdges=False, returnCost=False, returnInfo=False, silent=False)
Return up to k distinct simple paths in increasing cost order (Yen).
Non-negative edge costs and optional arrival vertex costs are supported. Filters/cost callbacks receive live records and must not mutate the graph. Parallel edge sequences count as distinct routes. Optional result flags append vertex records, edge records and cost to each index path, matching ShortestPath’s result convention. returnInfo returns paths, completed and timedOut. A time-limited result is a sorted prefix, never an unranked list.
- static Kernel(graphA: TGraph, graphB: TGraph, method: str = 'WL', key: str = None, labelKey: str = None, iterations: int = 2, maxHops: int = 2, hop: int = None, decay: float = 1.0, normalize: bool = True, mantissa: int = 6, silent: bool = False, **kwargs) Optional[float]
Returns a graph kernel similarity score between two input TGraphs.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’
The second input TGraph.
- methodstr , optional
The input method value. Default is ‘WL’.
- keystr , optional
The dictionary key to use. Default is None.
- labelKeystr , optional
The dictionary key to use. Default is None.
- iterationsint , optional
The input iterations value. Default is 2.
- maxHopsint , optional
The input max hops value. Default is 2.
- hopint , optional
The input hop value. Default is None.
- decayfloat , optional
The input decay value. Default is 1.0.
- normalizebool , optional
If set to True, returned values are normalized. Default is True.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[float]
The resulting kernel value.
- static KnowledgeGraphView(graph: TGraph, **kwargs)
Alias of TGraph.SemanticGraph for semantic graph visualisation.
- static Laplacian(graph, mode='all', silent=False, *, normalized=False, weightKey=None)
Return D-A, or the symmetric degree-normalized form.
Active vertices define row order. Parallel weights are summed; self-loops cancel in D-A. Undirected edges contribute both directions (loops once). Directed ‘out’ uses outgoing adjacency, ‘in’ its transpose, and ‘all’ symmetrizes arcs by addition. Normalization uses D^-1/2 L D^-1/2; zero-degree vertices have zero rows/columns in the undirected case. Directed normalized forms use the same algebra, not Chung’s Laplacian.
- static Leaves(graph: TGraph) List[Dict[str, Any]]
Returns the leaf vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- List[Dict[str, Any]]
The resulting leaves list.
- static LineGraph(graph: TGraph, directed: Optional[bool] = None, transferDictionaries: bool = True, vertexLabelKey: str = 'label', originalEdgeKey: str = 'original_edge_index', sharedVertexKey: str = 'shared_vertex_index', relationshipKey: str = 'relationship') Optional[TGraph]
Returns the line graph of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- directedOptional[bool] , optional
True treats every input edge as directed; False treats every edge as undirected. None preserves the input edge directions, including mixed graphs. Directed transitions require a legal exit and entry.
- transferDictionariesbool , optional
The input transfer dictionaries value. Default is True.
- vertexLabelKeystr , optional
The dictionary key to use. Default is ‘label’.
- originalEdgeKeystr , optional
The dictionary key to use. Default is ‘original_edge_index’.
- sharedVertexKeystr , optional
The dictionary key to use. Default is ‘shared_vertex_index’.
- relationshipKeystr , optional
The dictionary key to use. Default is ‘relationship’.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static LocalClusteringCoefficient(graph: TGraph, vertices: list = None, key: str = 'local_clustering_coefficient', mantissa: int = 6, silent: bool = False) List[float]
Computes local clustering coefficient values for the vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- verticeslist , optional
The input vertices or vertex indices. Default is None.
- keystr , optional
The dictionary key to use. Default is ‘local_clustering_coefficient’.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- List[float]
The resulting local clustering coefficient list.
- static LongestPath(graph, mode='all', silent=False, *, source=None, target=None, vertexKey=None, edgeKey=None, costKey=None, timeLimit=10, strategy='auto', returnInfo=False)
Search for a longest simple path, optionally between fixed endpoints.
strategy=’auto’ retains the historical diameter approximation without endpoints and selects exhaustive DFS with endpoints. ‘exact’/’dfs’ searches simple paths; ‘diameter’ selects the longest shortest path. Exact search is exponential and respects timeLimit. returnInfo reports path, cost, strategy, completed, timedOut and optimal. optimal is never true for the diameter heuristic. Costs are non-negative; edgeKey=None counts hops.
- static Match(graphA: TGraph, graphB: TGraph, vertexKeys: Any = None, edgeKeys: Any = None, maxMatches: int = 25, timeLimit: float = 5, exact: bool = False, silent: bool = False) List[Dict[int, int]]
Returns subgraph matches of a pattern graph in a target graph.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’
The second input TGraph.
- vertexKeysAny , optional
The input vertex keys value. Default is None.
- edgeKeysAny , optional
The input edge keys value. Default is None.
- maxMatchesint , optional
The input max matches value. Default is 25.
- timeLimitfloat , optional
The maximum time, in seconds, allowed for the search. Default is 5.
- exactbool , optional
The input exact value. Default is False.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- List[Dict[int, int]]
The resulting match list.
- static MaximumDelta(graph: TGraph, mode: str = 'all', silent: bool = False) Optional[int]
Returns the maximum vertex degree of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[int]
The resulting maximum delta index or count.
- static MaximumFlow(graph, source, sink, capacityKey='capacity', defaultCapacity=1.0, silent=False, *, edgeKeyFwd=None, edgeKeyBwd=None, bidirKey=None, bidirectional=None, flowKey=None, residualKey=None, returnDetails=False)
Return maximum flow, optionally with per-arc flow/residual details.
Forward/backward keys override capacityKey in their respective directions. Reverse traversal follows each edge’s directedness unless bidirectional or its per-edge bidirKey overrides it. Supplying edgeKeyBwd also enables a reverse arc when no explicit override is given. Parallel arcs retain IDs. flowKey/residualKey annotate each edge with forward/backward values; returnDetails returns the flow engine result, default remains a float.
- static MeanDepth(graph: TGraph, sources=None, mode: str = 'out', key=None, silent: bool = False) Dict[int, float]
Return mean unweighted hop depths, sharing adjacency across sources.
- Parameters
- graphTGraph
The input graph.
- sourcesiterable, optional
Vertex indices or records. None analyses all active vertices. Invalid sources are omitted.
- modestr, optional
“out”, “in”, or “all”. Other values use outgoing traversal.
- keystr, optional
Optional vertex attribute for the result. None writes no attributes.
- silentbool, optional
Reserved for consistency with other analysis methods.
- Returns
- Dict[int, float]
Source indices mapped to mean depth over reachable vertices, excluding the source. Isolated sources have value -1.0. One BFS is required per source; preparation is shared within a batch and reused through an attached AnalysisContext. Unreachable vertices are excluded. Edge lengths and weights are not used.
- static Merge(graphA: TGraph, graphB: TGraph, silent: bool = False, *, vertexKeys=None, edgeKeys=None, tolerance=None, useCentroid=False, matchBy=None, ambiguous='separate')
Returns a merged graph from two input TGraphs.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’
The second input TGraph.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static MergeVertices(graph: TGraph, *vertices, targetVertex=None, transferDictionaries: bool = True, tolerance: float = 0.0001, silent: bool = False) Optional[TGraph]
Merges several vertices into one target vertex and reconnects incident edges.
- Parameters
- graphTGraph
The input TGraph.
- *verticesint, dict, or list
Vertices to merge.
- targetVertexint or dict , optional
Optional target vertex. If omitted, the first valid input vertex is used. Default is None.
- transferDictionariesbool , optional
If set to True, missing target dictionary values are filled from merged vertices. 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
- TGraph or None
The modified input TGraph, or None if invalid.
- static MeshData(graph: TGraph, active: bool = True, *, includeDictionaries=False, includeIndices=False)
Returns mesh data representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- activebool , optional
If set to True, only active records are considered. Default is True.
- Returns
- Dict[str, Any]
The resulting mesh data dictionary.
- includeDictionaries adds copied vertexDictionaries/edgeDictionaries in mesh order.
- includeIndices adds stable IDs, allowing compact mesh incidence to be mapped back.
- static MetricDistance(graph: TGraph, vertexA: Any, vertexB: Any, mantissa: int = 6, silent: bool = False) Optional[float]
Returns a metric distance between two input TGraphs.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexAAny
The first input vertex or vertex index.
- vertexBAny
The second input vertex or vertex index.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[float]
The resulting metric distance value.
- static MinimumCut(graph: TGraph, source: Any, target: Any, cut: str = 'vertex', snapEndpoints: bool = True, tolerance: float = 1e-12, silent: bool = False, includeDetails: bool = False) Optional[Dict[str, Any]]
Returns the minimum source-target vertex or edge cut.
- Parameters
- graphTGraph
The input TGraph.
- sourceAny
The source vertex index or vertex-like input.
- targetAny
The target vertex index or vertex-like input.
- cutstr , optional
The cut type. Valid values are “vertex” and “edge”, together with common aliases. Default is “vertex”.
- snapEndpointsbool , optional
If True, unresolved vertex-like inputs are snapped to the nearest active TGraph vertex. Default is True.
- tolerancefloat , optional
Numerical tolerance used by the maximum-flow and residual-cut calculations. Default is 1e-12.
- silentbool , optional
If True, suppresses error messages. Default is False.
- includeDetailsbool , optional
If True, includes transformed residual-network details such as source-side nodes, target-side nodes, and cut arcs. These can be large for substantial graphs. Default is False.
- Returns
- dict or None
A dictionary describing the minimum cut, or None if the request is invalid.
The default returned dictionary contains:
- valuefloat
The maximum-flow/minimum-cut value.
- cutTypestr
Either “vertex” or “edge”.
- cutlist
Stable vertex indices for a vertex cut, or stable edge indices for an edge cut.
- sourceSidelist
Stable original graph vertex indices on the source side of the cut.
- targetSidelist
Stable original graph vertex indices on the target side of the cut.
- cutCapacityfloat
Capacity of the transformed minimum cut.
- isPureCutbool
True when the transformed minimum cut consists entirely of elements of the requested cut type.
- sourceint
Stable source vertex index.
- targetint
Stable target vertex index.
If includeDetails is True, the dictionary additionally contains:
- sourceSideNodeslist
Reachable transformed-network nodes.
- targetSideNodeslist
Unreachable transformed-network nodes.
- cutArcslist
Transformed-network arcs crossing the residual minimum cut.
For directly adjacent source and target vertices, an internal vertex separator may not exist. In such a case the transformed minimum cut can include the direct source-target edge and isPureCut can therefore be False.
- static MinimumDelta(graph: TGraph, mode: str = 'all', silent: bool = False) Optional[int]
Returns the minimum vertex degree of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[int]
The resulting minimum delta index or count.
- static MinimumSpanningTree(graph: TGraph, edgeKey: str = 'weight') Optional[TGraph]
Returns a minimum spanning tree of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- edgeKeystr , optional
The edge dictionary key to use. Default is ‘weight’.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
Returns a navigation graph derived from the input topology.
- Parameters
- faceAny
The input face value.
- verticesOptional[List[Any]] , optional
The input vertices or vertex indices. Default is None.
- obstaclesOptional[List[Any]] , optional
The input obstacles value. Default is None.
- bidirectionalbool , optional
The input bidirectional value. 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
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static NearestVertex(graph: TGraph, vertex: Any = None, x: float = 0, y: float = 0, z: float = 0, copy: bool = False, active: bool = False, asTopologic: bool = False, silent: bool = False) Optional[Dict[str, Any]]
Returns the nearest TGraph vertex record to the input coordinates, TGraph vertex index, TGraph vertex record, Topologic vertex, or coordinate list.
This implementation deliberately reads coordinates directly from the live TGraph vertex records, prioritising the vertex dictionary keys ‘x’, ‘y’, and ‘z’. This avoids stale geometric representations or cached coordinate data.
- Parameters
- graphTGraph
The input TGraph.
- vertexAny , optional
A TGraph vertex index, TGraph vertex record, Topologic vertex, or coordinate sequence. If specified, its coordinates override x, y, and z. Default is None.
- xfloat , optional
The X coordinate. Default is 0.
- yfloat , optional
The Y coordinate. Default is 0.
- zfloat , optional
The Z coordinate. Default is 0.
- copybool , optional
If True, a shallow copy of the record is returned, with a copied dictionary. If False, the live internal record is returned. Default is False.
- activebool , optional
If True, only active vertices are considered. If False, inactive vertices are also considered. Default is False.
- asTopologicbool , optional
If True, the result is returned as a Topologic vertex when possible. Default is False.
- silentbool , optional
If True, error and warning messages are suppressed. Default is False.
- Returns
- dict or topologic_core.Vertex or None
The nearest TGraph vertex record, or a Topologic vertex if asTopologic is True.
- static NeedsSemanticSync(graph: TGraph, key: str = 'semantic_fingerprint', **kwargs)
Returns True if the stored semantic fingerprint differs from the current one.
- static Neigborhood(graph: TGraph, vertices: list = None, k: int = 1, searchType: str = 'equal to', key: str = None, value: Any = None, direction: str = 'both', silent: bool = False) Optional[TGraph]
Returns a k-hop neighbourhood subgraph.
- Parameters
- graphTGraph
The input TGraph.
- verticeslist , optional
Seed vertices. If None, seed vertices are selected using key/value or all active vertices. Default is None.
- kint , optional
Hop distance. Default is 1.
- searchTypestr , optional
One of “equal to”, “less than”, “greater than”, “contains”, or “not equal to”. Used only when key is specified. Default is “equal to”.
- keystr , optional
Vertex dictionary key used to select seed vertices. Default is None.
- valueAny , optional
Value used with key/searchType. Default is None.
- directionstr , optional
Traversal direction: “in”, “out”, or “both”. Default is “both”.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph or None
The resulting neighbourhood subgraph.
- static Neighborhood(graph: TGraph, vertices: list = None, k: int = 1, searchType: str = 'equal to', key: str = None, value: Any = None, direction: str = 'both', silent: bool = False) Optional[TGraph]
Correctly spelled alias for TGraph.Neigborhood.
- static NetworkXGraph(graph: TGraph, nodeIDKey: str = None, edgeIDKey: str = None, includeInactive: bool = False, scalarAttributes: bool = False) Optional[Any]
Returns a NetworkX graph representation of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- nodeIDKeystr , optional
The dictionary key to use. Default is None.
- edgeIDKeystr , optional
The dictionary key to use. Default is None.
- includeInactivebool , optional
If set to True, include inactive are included. Default is False.
- scalarAttributesbool , optional
The input scalar attributes value. Default is False.
- Returns
- Optional[Any]
The resulting network xgraph object or value.
- static NormalizeOntologyDictionaries(graph: TGraph, labelKeys: Optional[List[str]] = None, categoryKeys: Optional[List[str]] = None, ifcClassKeys: Optional[List[str]] = None, ifcGUIDKeys: Optional[List[str]] = None, includeGraph: bool = True, includeVertices: bool = True, includeEdges: bool = True) Optional[TGraph]
Normalizes ontology dictionaries exclusively through Ontology.py.
- static OntologyAnnotateGraph(*args, **kwargs) Optional[TGraph]
Annotates graph, vertex, and edge dictionaries with ontology metadata.
- Parameters
- *argsAny , optional
Additional positional arguments.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static OntologyCategory(graph: TGraph, element: str = 'graph', index: Optional[int] = None, defaultValue: Any = None) Any
Returns the ontology category of a graph, vertex, or edge.
- Parameters
- graph‘TGraph’
The input TGraph.
- elementstr , optional
The graph element to annotate or query. Valid values are typically “graph”, “vertex”, or “edge”. Default is ‘graph’.
- indexOptional[int] , optional
The input index. Default is None.
- defaultValueAny , optional
The default value to return when no valid value is found. Default is None.
- Returns
- Any
The resulting ontology category object or value.
- static OntologyClass(graph: TGraph, element: str = 'graph', index: Optional[int] = None, defaultValue: Any = None) Any
Returns the canonical ontology class of a graph, vertex, or edge.
- static OntologyClassByIFCClass(ifcClass: str, defaultValue: Any = 'top:Element') Any
Returns the canonical TopologicPy ontology class for an IFC class.
- static OntologyLabel(graph: TGraph, element: str = 'graph', index: Optional[int] = None, defaultValue: Any = None) Any
Returns the ontology label of a graph, vertex, or edge.
- Parameters
- graph‘TGraph’
The input TGraph.
- elementstr , optional
The graph element to annotate or query. Valid values are typically “graph”, “vertex”, or “edge”. Default is ‘graph’.
- indexOptional[int] , optional
The input index. Default is None.
- defaultValueAny , optional
The default value to return when no valid value is found. Default is None.
- Returns
- Any
The resulting ontology label object or value.
- static OntologyTriples(graph: TGraph, includeVertices: bool = True, includeEdges: bool = True, includeDictionaries: bool = True, includeBOT: bool = True, namespacePrefix: str = 'inst') List[Tuple[Any, Any, Any]]
Returns canonical RDF triples for a TGraph.
Ontology.py owns serialization semantics. TGraph deliberately contains no duplicate serializer, vocabulary tables, aliases, or fallback terms.
- static OntologyURI(graph: TGraph, element: str = 'graph', index: Optional[int] = None, defaultValue: Any = None) Any
Returns the ontology URI of a graph, vertex, or edge.
- Parameters
- graph‘TGraph’
The input TGraph.
- elementstr , optional
The graph element to annotate or query. Valid values are typically “graph”, “vertex”, or “edge”. Default is ‘graph’.
- indexOptional[int] , optional
The input index. Default is None.
- defaultValueAny , optional
The default value to return when no valid value is found. Default is None.
- Returns
- Any
The resulting ontology uri object or value.
- static Order(graph: TGraph) int
Returns the number of active vertices in the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- int
The number of active vertices.
- static Originators(graph, originators=None, silent: bool = False)
Returns source topologies in active-node order, with None for missing links.
- static OutgoingEdges(graph: TGraph, vertex: Union[int, Dict[str, Any]]) List[Dict[str, Any]]
Returns the outgoing edges of the input vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- Returns
- List[Dict[str, Any]]
The resulting outgoing edges list.
- static OutgoingVertices(graph: TGraph, vertex: Union[int, Dict[str, Any]]) List[Dict[str, Any]]
Returns the outgoing adjacent vertices of the input vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- Returns
- List[Dict[str, Any]]
The resulting outgoing vertices list.
- static PageRank(graph: TGraph, damping: float = 0.85, iterations: int = 100, tolerance: float = 1e-09, key: str = 'pagerank', mantissa: int = 6, useNumpy: bool = True) List[float]
Computes PageRank values for the vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- dampingfloat , optional
The input damping value. Default is 0.85.
- iterationsint , optional
The input iterations value. Default is 100.
- tolerancefloat , optional
The desired tolerance. Default is 1e-09.
- keystr , optional
The dictionary key to use. Default is ‘pagerank’.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- useNumpybool , optional
If set to True, NumPy acceleration is used when available. Default is True.
- Returns
- List[float]
The resulting page rank list.
- static Partition(graph: TGraph, method: str = 'Betweenness', n: int = 2, m: int = 10, key: str = 'partition', mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False) Optional[TGraph]
Partitions the input graph and stores partition ids in dictionaries.
- Parameters
- graphTGraph
The input TGraph.
- methodstr , optional
Partition method: “Betweenness”, “Community”/”Louvain”, or “Fiedler”/”Eigen”. Default is “Betweenness”.
- nint , optional
Desired number of partitions for betweenness partitioning. Default is 2.
- mint , optional
Maximum number of tries for betweenness partitioning. Default is 10.
- keystr , optional
Dictionary key under which to store partition ids. Default is “partition”.
- mantissaint , optional
Number of decimal places for numeric calculations. 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
- TGraph or None
The input TGraph after annotation, or None if invalid.
- static Path(graph: TGraph, vertexA, vertexB, tolerance: float = 0.0001, silent: bool = False) List[int]
Returns a least-cost path between two vertices of the input TGraph.
This is a convenience wrapper around TGraph.ShortestPath using its default geometric-length cost.
- Parameters
- graphTGraph
The input TGraph.
- vertexAAny
The first input vertex. This may be a stable vertex index, TGraph vertex record, Topologic vertex, or coordinate-like input.
- vertexBAny
The second input vertex. This may be a stable vertex index, TGraph vertex record, Topologic vertex, or coordinate-like input.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If True, error and warning messages are suppressed. Default is False.
- Returns
- list or None
The ordered list of stable TGraph vertex indices forming the path.
- static PathLength(graph: TGraph, path: list, mantissa: int = 6, silent: bool = False) Optional[float]
Computes the geometric length of a TGraph path by summing the Euclidean distances between consecutive vertex coordinates.
The path is expected to be a list of TGraph vertex indices. This method reads coordinates directly from the TGraph vertex dictionaries for speed.
- Parameters
- graphTGraph
The input TGraph.
- pathlist
A list of TGraph vertex indices.
- mantissaint , optional
Number of decimal places in the returned value. If None or negative, the value is not rounded. Default is 6.
- silentbool , optional
If True, warnings are suppressed. Default is False.
- Returns
- float or None
The geometric length of the path, or None if the graph/path is invalid.
- static ProofGraph(graph: TGraph, triple=None, subject=None, predicate=None, object=None, result=None, silent: bool = False, **kwargs)
Returns proof-graph data for a semantic fact.
- static ProofGraphData(graph: TGraph, triple=None, subject=None, predicate=None, object=None, result=None, silent: bool = False, **kwargs)
Returns Plotly-ready proof-graph data for a semantic fact.
- static ProofGraphFigure(graph: TGraph, triple=None, subject=None, predicate=None, object=None, result=None, silent: bool = False, **kwargs)
Returns a Plotly figure visualising a proof graph.
- static ProofGraphHTML(graph: TGraph, triple=None, subject=None, predicate=None, object=None, result=None, path: str = 'proof_graph.html', silent: bool = False, **kwargs)
Exports a proof-graph visualisation to an HTML file.
- static PropagateValues(graph: TGraph, 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) Optional[TGraph]
Propagates dictionary values from source vertices to target vertices along selected edges.
- Parameters
- graphTGraph
The input TGraph.
- 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
Source dictionary keys to copy. If None, all non-reserved source keys are considered. Default is None.
- targetKeyslist , optional
Target dictionary keys. If None, sourceKeys are used with prefix/suffix. Default is None.
- directionstr , optional
“out”, “in”, or “both”. Default is “out”.
- overwritebool , optional
If True, existing target values are overwritten. 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
Included for API compatibility. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph or None
The input graph after propagation, or None if invalid.
- static PyvisGraph(graph, height='750px', width='100%', directed=None, vertexLabelKey='label', edgeLabelKey='label', notebook=False, bgcolor='#ffffff', fontColor='#000000', silent=False, *, vertexSize=6, vertexSizeKey=None, vertexColor=None, vertexColorKey=None, vertexGroupKey=None, vertexGroups=None, edgeColor=None, edgeColorKey=None, edgeWeight=None, edgeWeightKey=None, selectMenu=False, filterMenu=False, showNeighbours=True, colorScale='viridis', vertexAttributes=None, edgeAttributes=None)
Create a styled Pyvis Network; write HTML explicitly with write_html.
Dictionary keys override fixed sizes/colors/weights. Groups are retained as Pyvis groups; vertexGroups optionally maps categories to colors from colorScale. Constant vertexAttributes/edgeAttributes are also supported. Attribute tooltips are escaped. Missing Pyvis raises an install hint.
- 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: bool = False, silent: bool = False) Optional[TGraph]
Constructs the quotient graph induced by grouping TGraph vertices by a dictionary value.
Two groups are connected if any member vertex of one group is adjacent to any member vertex of the other group. If weighted is True, edge weights count the number of distinct member-level adjacencies across groups.
- Parameters
- topologyTGraph
The input TGraph.
- topologyTypestr , optional
The type of item to quotient. Supported values are “vertex” and “edge”. If set to “edge”, the line graph of the input TGraph is constructed first, then quotienting is performed on the line-graph vertices. Default is “vertex”.
- keystr
The vertex dictionary key used to form groups.
- groupLabelKeystr , optional
Vertex dictionary key under which to store the group label. If set to None, the input key is used. Default is None.
- groupCountKeystr , optional
Vertex dictionary key under which to store the group size. Default is “count”.
- weightedbool , optional
If set to True, stores counts of cross-group adjacencies on quotient edges under edgeWeightKey. Default is False.
- edgeWeightKeystr , optional
Edge dictionary key under which to store the weight when weighted is True. Default is “weight”.
- idKeystr , optional
Kept for API compatibility with Graph.Quotient. Not required for TGraph, because TGraph vertices already have stable integer indices. Default is None.
- transferDictionariesbool , optional
If set to True, dictionaries of grouped member vertices are merged into the representative quotient vertex. Default is False.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph or None
The resulting quotient TGraph, or None if the operation fails.
- static RDFGraph(graph: TGraph, includeOntologyAxioms: bool = False, includeBOT: bool = True, silent: bool = False, **kwargs)
Returns an RDFLib graph for the input TGraph when RDFLib is available.
- static RDFString(*args, **kwargs) Optional[str]
Returns an RDF/Turtle string representation of the input TGraph.
- Parameters
- *argsAny , optional
Additional positional arguments.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- Optional[str]
The resulting rdfstring string.
- RemoveEdge(edge: Union[int, Dict[str, Any]], silent: bool = False) TGraph
Removes an edge from this TGraph.
- Parameters
- edgeUnion[int, Dict[str, Any]]
The input edge, edge index, or edge record.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph
The resulting TGraph, or None if the operation fails.
- static RemoveIsolatedEdges(graph, silent=False, *, removeVertices=True, removeInvalid=True)
Remove standalone edge components; optionally remove their vertices.
Classification uses the original active incidence, so removing one edge never cascades through a chain. Parallel edges and self-loops are retained. removeInvalid also cleans records referencing inactive/missing endpoints.
- static RemoveIsolatedVertices(graph: TGraph, mode: str = 'all', silent: bool = False) Optional[TGraph]
Removes isolated vertices from the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- RemoveVertex(vertex: Union[int, Dict[str, Any]], silent: bool = False) TGraph
Removes a vertex and its incident edges from this TGraph.
- Parameters
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph
The resulting TGraph, or None if the operation fails.
- static Reshape(graph: TGraph, shape='spring 2D', k=0.8, seed=None, iterations=50, rootVertex=None, size=1, factor=1, sides=16, key='', tolerance=0.0001, silent=False) Optional[TGraph]
Repositions TGraph vertex coordinates using a simple layout algorithm.
- Parameters
- graphTGraph
The input TGraph.
- shapestr , optional
Layout name. Supported values include “spring 2D”, “circle”, “circular”, “random”, and “line”. Default is “spring 2D”.
- kfloat , optional
Spring-layout ideal distance factor. Default is 0.8.
- seedint , optional
Random seed. Default is None.
- iterationsint , optional
Number of spring iterations. Default is 50.
- rootVertexint or dict , optional
Optional root vertex for line/tree-style layouts. Default is None.
- sizefloat , optional
Overall layout size. Default is 1.
- factorfloat , optional
Additional coordinate scale factor. Default is 1.
- sidesint , optional
Included for API compatibility. Default is 16.
- keystr , optional
Optional dictionary key whose values may influence ordering. 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
- TGraph or None
The reshaped graph, or None if invalid.
- static SegmentGraph(edges, tolerance: float = 0.0001, silent: bool = False)
Splits straight input Edges at 3D contacts and creates segment nodes.
Each node’s originator/representation is the generated segment Edge. edge_id is a stable segment UUID; parent_edge_id links to the input Edge UUID, with its live reference stored as parent_originator. Connections store angular_weight in quarter-turn units (straight cost 0). Angular wrappers recognize this graph and analyse its nodes directly. Collinear overlaps are split at both ends and coincident segments are deduplicated within tolerance. parent_edge_ids and parent_originators preserve every source; singular parent fields retain the first source. Source dictionaries are also retained under parent_dictionaries.
- static SemanticDiff(graphA, graphB, **kwargs)
Returns a semantic triple diff between two TGraphs or knowledge graphs.
- static SemanticFingerprint(graph: TGraph, includeOntologyAxioms: bool = False, **kwargs)
Returns a deterministic hash of the TGraph semantic triples.
- static SemanticGraph(graph: TGraph, **kwargs)
Returns the semantic KnowledgeGraph converted back to a TGraph view.
- static SemanticSummary(graph: TGraph, **kwargs)
Returns a summary of semantic content in the TGraph.
- SetDictionary(dictionary: Optional[Dict[str, Any]] = None) TGraph
Sets the dictionary of this TGraph.
- Parameters
- dictionaryOptional[Dict[str, Any]] , optional
The input dictionary. Default is None.
- Returns
- TGraph
The resulting TGraph, or None if the operation fails.
- SetEdgeDictionary(index: Any, dictionary: Optional[Dict[str, Any]] = None) TGraph
Sets the dictionary of an edge in this TGraph.
Structural edge fields are preserved automatically.
- Parameters
- indexint or dict
The edge index or edge record.
- dictionarydict , optional
The replacement dictionary. Default is None.
- Returns
- TGraph
The input TGraph.
- SetEdgeValue(edge: Any, key: str, value: Any, silent: bool = False) TGraph
Sets a dictionary value on an edge.
- Parameters
- edgeint or dict
The edge index or edge record.
- keystr
The dictionary key.
- valueAny
The value to store.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph
The input TGraph.
- static SetOntologyCategory(graph: TGraph, category: str, element: str = 'graph', index: Optional[int] = None) Optional[TGraph]
Sets the ontology category of a graph, vertex, or edge.
- static SetOntologyClass(graph: TGraph, ontologyClass: str, element: str = 'graph', index: Optional[int] = None, setCategory: bool = True, setURI: bool = True) Optional[TGraph]
Sets a declared canonical ontology class on a graph, vertex, or edge.
- static SetOntologyLabel(graph: TGraph, label: Any, element: str = 'graph', index: Optional[int] = None) Optional[TGraph]
Sets the ontology label of a graph, vertex, or edge.
- static SetOntologyURI(graph: TGraph, uri: str, element: str = 'graph', index: Optional[int] = None) Optional[TGraph]
Sets the explicit RDF resource URI of a graph, vertex, or edge.
- static SetVertexCoordinates(graph: TGraph, vertexIndex: int, x=None, y=None, z=None, coordinates=None, silent: bool = False) bool
Sets the X, Y, Z coordinates of a TGraph vertex in-place.
Coordinates are stored in the vertex dictionary using keys ‘x’, ‘y’, and ‘z’. If the vertex has a Topologic representation, this method does not rebuild that representation. It only updates the lightweight TGraph record.
- Parameters
- graphTGraph
The input TGraph.
- vertexIndexint
The vertex index.
- x, y, zfloat , optional
Coordinate values to set. Omitted values are left unchanged.
- coordinateslist or tuple , optional
Optional coordinate sequence. If supplied, it overrides x, y, z.
- silentbool , optional
If True, error messages are suppressed. Default is False.
- Returns
- bool
True if successful, otherwise False.
- SetVertexDictionary(index: Any, dictionary: Optional[Dict[str, Any]] = None) TGraph
Sets the dictionary of a vertex in this TGraph.
Structural vertex fields are preserved automatically.
- Parameters
- indexint or dict
The vertex index or vertex record.
- dictionarydict , optional
The replacement dictionary. Default is None.
- Returns
- TGraph
The input TGraph.
- static SetVertexOriginator(graph, vertex, originator, silent: bool = False)
Links a node to its source topology independently of its representation.
Stores the exact live object, its persistent Topology.UUID and its type. The UUID is also stored as originator_id in the node dictionary so it can survive JSON export. A missing UUID is created on the source topology. Passing None explicitly clears the link. Returns the input graph or None.
- SetVertexValue(vertex: Any, key: str, value: Any, silent: bool = False) TGraph
Sets a dictionary value on a vertex.
- Parameters
- vertexint or dict
The vertex index or vertex record.
- keystr
The dictionary key.
- valueAny
The value to store.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- TGraph
The input TGraph.
- static ShortestPath(graph: TGraph, source: Any, target: Any, mode: str = 'out', useNumba: bool = False, vertexKey: str = '', edgeKey: str = 'Length', turnWeight: float = 0.0, turnPower: float = 1.0, turnKey: str = '', directed: Optional[bool] = None, 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, returnCost: bool = False, snapEndpoints: bool = True, tolerance: float = 0.0001, silent: bool = False)
Returns a least-cost path between two vertices of the input TGraph.
The default cost is geometric edge length. The method also supports vertex costs, edge dictionary costs, turn penalties, custom filters and cost functions, directed traversal, A* search, and unweighted hop-count routing.
- Parameters
- graphTGraph
The input TGraph.
- sourceAny
The source vertex. This may be a stable vertex index, a TGraph vertex record, a Topologic vertex, or a coordinate sequence.
- targetAny
The target vertex. This may be a stable vertex index, a TGraph vertex record, a Topologic vertex, or a coordinate sequence.
- modestr , optional
Traversal mode: “out”, “in”, or “all”. “out” respects stored directed edges, “in” traverses directed edges in reverse, and “all” treats all edges as bidirectional. Undirected edges are bidirectional in every mode. Default is “out”.
- useNumbabool , optional
If True, Numba acceleration is used when available for pure hop-count routing (edgeKey=”hop”) when no advanced routing options require the Python engine. Default is False.
- vertexKeystr , optional
Numeric vertex dictionary key added to the cost when a vertex is entered. The source cost is always zero. Default is “”.
- edgeKeystr , optional
Numeric edge dictionary key used as traversal cost. “Length”, “Distance”, or “Metric” uses Euclidean endpoint distance. “hop”, “hops”, “unweighted”, or “unit” assigns cost 1 to every edge. Empty or None uses geometric length. Default is “Length”.
- turnWeightfloat , optional
Multiplier for the built-in turn penalty. Zero disables it. Default is 0.
- turnPowerfloat , optional
Exponent applied to normalized turn severity. Default is 1.
- turnKeystr , optional
Numeric vertex dictionary key that locally scales built-in turn cost. Missing values default to 1. Default is “”.
- directedbool , optional
Compatibility override for Graph.ShortestPath. True is equivalent to mode=”out”; False is equivalent to mode=”all”; None uses mode. Default is None.
- edgeFiltercallable(edgeRecord) -> bool , optional
Returns False for edges that may not be traversed. Default is None.
- vertexFiltercallable(vertexRecord) -> bool , optional
Returns False for vertices that may not be visited. Source and target are always allowed. Default is None.
- edgeCostFunccallable(edgeRecord) -> float , optional
Custom edge cost. Overrides edgeKey. Default is None.
- vertexCostFunccallable(vertexRecord) -> float , optional
Custom vertex cost. Overrides vertexKey. Default is None.
- turnCostFunccallable(prevVertex, currentVertex, nextVertex,
inEdge, outEdge, spread) -> float , optional
Custom turn cost. Vertex and edge arguments are TGraph records. spread is normalized to [0, 1], where 0 is straight and 1 is a reversal. Overrides turnWeight, turnPower, and turnKey. Default is None.
- useAStarbool , optional
If True, A* is used when geometric edge length is the base edge cost. Otherwise Dijkstra search is used. Default is False.
- heuristicScalefloat , optional
Euclidean A* heuristic multiplier clamped to [0, 1]. Default is 1.
- returnVerticesbool , optional
If True, also returns the ordered live TGraph vertex records. Default is False.
- returnEdgesbool , optional
If True, also returns the ordered live TGraph edge records. Default is False.
- returnCostbool , optional
If True, also returns the total routing cost. Default is False.
- snapEndpointsbool , optional
If True, unresolved source/target inputs are snapped to the nearest active TGraph vertices. Default is True.
- tolerancefloat , optional
The desired tolerance. Retained for API compatibility. Default is 0.0001.
- silentbool , optional
If True, error and warning messages are suppressed. Default is False.
- Returns
- list or tuple or None
By default, the ordered list of stable vertex indices. Optional return data are appended in this order: vertex records, edge records, total cost. Returns None if no path exists.
- static ShortestPathTree(graph: TGraph, source, mode: str = 'out', useNumba: bool = False, includePaths: bool = False, includeEdges: bool = False, vertexKey: str = '', edgeKey: str = 'Length', directed=None, edgeFilter: callable = None, vertexFilter: callable = None, edgeCostFunc: callable = None, vertexCostFunc: callable = None, snapEndpoints: bool = True, tolerance: float = 0.0001, silent: bool = False, useSciPy: bool = False)
Returns a least-cost shortest-path tree rooted at the input source vertex.
The tree supports the same additive edge and vertex costs as TGraph.ShortestPath. Turn-dependent costs are intentionally not accepted: when path cost depends on the incoming edge, a single parent per vertex is not mathematically sufficient to represent all shortest paths.
- Parameters
- graphTGraph
The input TGraph.
- sourceAny
The source vertex. This may be a stable vertex index, TGraph vertex record, Topologic vertex, or coordinate-like input.
- modestr , optional
Traversal mode: “out”, “in”, or “all”. Default is “out”.
- useNumbabool , optional
If True, Numba acceleration is used when available for pure hop-count routing. Default is False.
- includePathsbool , optional
If True, the returned dictionary includes complete vertex paths from the source to every reachable vertex. Default is False.
- includeEdgesbool , optional
If True, the returned dictionary includes ordered edge-index paths. Default is False.
- vertexKeystr , optional
Numeric vertex dictionary key added to the cost when a vertex is entered. Default is “”.
- edgeKeystr , optional
Numeric edge dictionary key used as traversal cost. “Length”, “Distance”, or “Metric” uses geometric edge length. “hop”, “hops”, “unweighted”, or “unit” uses unit edge cost. Default is “Length”.
- directedbool , optional
Compatibility override. True is equivalent to mode=”out”; False is equivalent to mode=”all”; None uses mode. Default is None.
- edgeFiltercallable(edgeRecord) -> bool , optional
Returns False for edges that may not be traversed. Default is None.
- vertexFiltercallable(vertexRecord) -> bool , optional
Returns False for vertices that may not be traversed. The source vertex is always allowed. Default is None.
- edgeCostFunccallable(edgeRecord) -> float , optional
Custom edge cost overriding edgeKey. Default is None.
- vertexCostFunccallable(vertexRecord) -> float , optional
Custom vertex cost overriding vertexKey. Default is None.
- snapEndpointsbool , optional
If True, unresolved source input is snapped to the nearest active graph vertex. Default is True.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If True, error and warning messages are suppressed. Default is False.
- useSciPybool, optional
Request sparse routing for ordinary hop or positive integer edge costs. Default False avoids preparation overhead for isolated calls. With useSciPy=True, an enabled AnalysisContext reuses sparse preparation. Fractional/zero costs, filters, and callbacks retain Python routing.
- Returns
- dict or None
A dictionary containing:
source: resolved source vertex index
mode: traversal mode
parent: predecessor vertex for each vertex
parentEdge: predecessor edge for each vertex
distance: least routing cost from the source
hops: number of edges from the source
reachable: reachable vertex indices
paths: optional complete vertex paths
edgePaths: optional complete edge-index paths
- static ShortestPathViaVertices(graph: TGraph, startVertex, endVertex, vertices: list = None, optimize: bool = False, tolerance: float = 0.0001, silent: bool = False, vertexKey: str = '', viaKey: str = None, viaValues: list = None, edgeKey: str = 'Length', turnWeight: float = 0.0, turnPower: float = 1.0, turnKey: str = '', mode: str = 'out', useNumba: bool = False, directed=None, 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, returnCost: bool = False, snapEndpoints: bool = True)
Returns a least-cost path that passes through required vertices in order.
Required vertices can be supplied directly through vertices, or selected by matching viaValues against the vertex dictionary key viaKey. Explicit vertices take precedence when both mechanisms are supplied.
- Parameters
- graphTGraph
The input TGraph.
- startVertexAny
The start vertex.
- endVertexAny
The end vertex.
- verticeslist , optional
Ordered intermediate vertices through which the path must pass. Default is None.
- optimizebool , optional
If True, removable loops are erased after the route is assembled. Loops are removed only when all required vertices remain present in the requested order. Default is False.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If True, error and warning messages are suppressed. Default is False.
- vertexKeystr , optional
Numeric vertex dictionary key added to path cost. Default is “”.
- viaKeystr , optional
Vertex dictionary key used to locate required via vertices when vertices is None. Default is None.
- viaValueslist , optional
Ordered dictionary values to locate through viaKey. Default is None.
- edgeKeystr , optional
Edge cost key. “Length” uses geometric length. Default is “Length”.
- turnWeightfloat , optional
Built-in turn-cost multiplier. Default is 0.
- turnPowerfloat , optional
Turn severity exponent. Default is 1.
- turnKeystr , optional
Vertex dictionary key used to scale turn cost. Default is “”.
- modestr , optional
Traversal mode: “out”, “in”, or “all”. Default is “out”.
- useNumbabool , optional
If True, Numba acceleration is used where applicable. Default is False.
- directedbool , optional
Compatibility direction override. Default is None.
- edgeFiltercallable , optional
Edge traversal filter. Default is None.
- vertexFiltercallable , optional
Vertex traversal filter. Default is None.
- edgeCostFunccallable , optional
Custom edge cost function. Default is None.
- vertexCostFunccallable , optional
Custom vertex cost function. Default is None.
- turnCostFunccallable , optional
Custom turn cost function. Default is None.
- useAStarbool , optional
If True, A* is used for segment searches when applicable. Default is False.
- heuristicScalefloat , optional
A* heuristic multiplier. Default is 1.
- returnVerticesbool , optional
If True, ordered TGraph vertex records are also returned. Default is False.
- returnEdgesbool , optional
If True, ordered TGraph edge records are also returned. Default is False.
- returnCostbool , optional
If True, total cost of the complete returned route is also returned. Default is False.
- snapEndpointsbool , optional
If True, unresolved inputs are snapped to nearest active graph vertices. Default is True.
- Returns
- list or tuple or None
By default, the ordered stable vertex indices. Optional data are appended in this order: vertex records, edge records, total cost.
- static ShortestPaths(graph: TGraph, pairs, mode: str = 'out', useNumba: bool = False, grouped='auto', groupThreshold: float = 1.5, vertexKey: str = '', edgeKey: str = 'Length', turnWeight: float = 0.0, turnPower: float = 1.0, turnKey: str = '', directed=None, 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, returnCost: bool = False, snapEndpoints: bool = True, tolerance: float = 0.0001, silent: bool = False)
Returns least-cost paths for all requested source-target pairs.
The current TGraph meaning of ShortestPaths is preserved: this is a batch operation over source-target pairs, not a k-shortest-alternative-paths operation.
- Parameters
- graphTGraph
The input TGraph.
- pairsiterable
An iterable of (source, target) pairs.
- modestr , optional
Traversal mode: “out”, “in”, or “all”. Default is “out”.
- useNumbabool , optional
If True, Numba acceleration is used where applicable. Default is False.
- groupedbool or str , optional
If True, requests sharing a source are grouped and solved together. If “auto”, grouping is selected using groupThreshold. Default is “auto”.
- groupThresholdfloat , optional
Minimum average targets per source required for automatic grouping. Default is 1.5.
- vertexKeystr , optional
Numeric vertex dictionary cost key. Default is “”.
- edgeKeystr , optional
Edge cost key. “Length” uses geometric length. Default is “Length”.
- turnWeightfloat , optional
Built-in turn-cost multiplier. Default is 0.
- turnPowerfloat , optional
Turn severity exponent. Default is 1.
- turnKeystr , optional
Vertex dictionary key used to scale turn cost. Default is “”.
- directedbool , optional
Compatibility direction override. Default is None.
- edgeFiltercallable , optional
Edge traversal filter. Default is None.
- vertexFiltercallable , optional
Vertex traversal filter. Default is None.
- edgeCostFunccallable , optional
Custom edge cost function. Default is None.
- vertexCostFunccallable , optional
Custom vertex cost function. Default is None.
- turnCostFunccallable , optional
Custom turn cost function. Default is None.
- useAStarbool , optional
If True, A* is used for individual searches when applicable. Default is False.
- heuristicScalefloat , optional
A* heuristic multiplier. Default is 1.
- returnVerticesbool , optional
If True, vertex records are also returned for each path. Default is False.
- returnEdgesbool , optional
If True, edge records are also returned for each path. Default is False.
- returnCostbool , optional
If True, total routing cost is also returned for each path. Default is False.
- snapEndpointsbool , optional
If True, unresolved endpoints are snapped to active graph vertices. Default is True.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If True, error and warning messages are suppressed. Default is False.
- Returns
- list
Path results corresponding one-to-one with the input pairs.
- static ShortestPathsFromSource(graph: TGraph, source, targets=None, mode: str = 'out', useNumba: bool = False, returnTree: bool = False, vertexKey: str = '', edgeKey: str = 'Length', turnWeight: float = 0.0, turnPower: float = 1.0, turnKey: str = '', directed=None, 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, returnCost: bool = False, snapEndpoints: bool = True, tolerance: float = 0.0001, silent: bool = False, useSciPy: bool = False)
Returns least-cost paths from one source vertex to the requested targets.
For ordinary additive edge and vertex costs, one shortest-path tree is reused for efficiency. If turn-dependent costs or a vertex filter are supplied, each target is solved independently using TGraph.ShortestPath so that the results remain exactly consistent with that method.
- Parameters
- graphTGraph
The input TGraph.
- sourceAny
The source vertex.
- targetsiterable , optional
The target vertices. If None, all active graph vertices are used.
- modestr , optional
Traversal mode: “out”, “in”, or “all”. Default is “out”.
- useNumbabool , optional
If True, Numba acceleration is used where applicable. Default is False.
- returnTreebool , optional
If True, the reusable shortest-path tree is returned under the “_tree” key when such a tree is mathematically valid. Default is False.
- vertexKeystr , optional
Numeric vertex dictionary cost key. Default is “”.
- edgeKeystr , optional
Edge cost key. “Length” uses geometric length. Default is “Length”.
- turnWeightfloat , optional
Built-in turn-cost multiplier. Default is 0.
- turnPowerfloat , optional
Turn severity exponent. Default is 1.
- turnKeystr , optional
Vertex dictionary key used to scale turn cost. Default is “”.
- directedbool , optional
Compatibility direction override. Default is None.
- edgeFiltercallable , optional
Edge traversal filter. Default is None.
- vertexFiltercallable , optional
Vertex traversal filter. Default is None.
- edgeCostFunccallable , optional
Custom edge cost function. Default is None.
- vertexCostFunccallable , optional
Custom vertex cost function. Default is None.
- turnCostFunccallable , optional
Custom turn cost function. Default is None.
- useAStarbool , optional
If True, A* is used for individual target searches when applicable. Default is False.
- heuristicScalefloat , optional
A* heuristic multiplier. Default is 1.
- returnVerticesbool , optional
If True, path vertex records are also returned. Default is False.
- returnEdgesbool , optional
If True, path edge records are also returned. Default is False.
- returnCostbool , optional
If True, total routing cost is also returned. Default is False.
- snapEndpointsbool , optional
If True, unresolved endpoints are snapped to active graph vertices. Default is True.
- tolerancefloat , optional
The desired tolerance. Default is 0.0001.
- silentbool , optional
If True, error and warning messages are suppressed. Default is False.
- useSciPybool, optional
Request sparse routing for ordinary hop or positive integer edge costs. Default False avoids preparation overhead for isolated calls. With useSciPy=True, an enabled AnalysisContext reuses sparse preparation. Fractional/zero costs, filters, and callbacks retain Python routing.
- Returns
- dict
A dictionary mapping target vertices or resolved target indices to path results.
- static Show(*graphs, sagitta=0, absolute=False, sides=8, angle=0, vertexColor='black', vertexColorKey='color', vertexSize=10, vertexSizeKey='size', vertexLabelKey=None, vertexGroupKey=None, vertexGroups=None, vertexMinGroup=None, vertexMaxGroup=None, showVertices=True, showVertexLabel=False, showVertexLegend=False, edgeColor='red', edgeColorKey='color', edgeWidth=1, edgeWidthKey='width', edgeLabelKey=None, edgeGroupKey=None, edgeGroups=None, 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)
Displays a representation of the input TGraph.
- Parameters
- *graphsAny , optional
The input list of TGraphs.
- sagittaAny , optional
The input sagitta value. Default is 0.
- absoluteAny , optional
The input absolute value. Default is False.
- sidesAny , optional
The input sides value. Default is 8.
- angleAny , optional
The input angle value. Default is 0.
- vertexColorAny , optional
The color value to use. Default is ‘black’.
- vertexColorKeyAny , optional
The dictionary key to use. Default is None.
- vertexSizeAny , optional
The input vertex size value. Default is 10.
- vertexSizeKeyAny , optional
The dictionary key to use. Default is None.
- vertexLabelKeyAny , optional
The dictionary key to use. Default is None.
- vertexGroupKeyAny , optional
The dictionary key to use. Default is None.
- vertexGroupsAny , optional
The input vertex groups value. Default is [].
- vertexMinGroupAny , optional
The input vertex min group value. Default is None.
- vertexMaxGroupAny , optional
The input vertex max group value. Default is None.
- showVerticesAny , optional
If set to True, show vertices are shown. Default is True.
- showVertexLabelAny , optional
If set to True, show vertex label are shown. Default is False.
- showVertexLegendAny , optional
If set to True, show vertex legend are shown. Default is False.
- edgeColorAny , optional
The color value to use. Default is ‘red’.
- edgeColorKeyAny , optional
The dictionary key to use. Default is None.
- edgeWidthAny , optional
The input edge width value. Default is 1.
- edgeWidthKeyAny , optional
The dictionary key to use. Default is None.
- edgeLabelKeyAny , optional
The dictionary key to use. Default is None.
- edgeGroupKeyAny , optional
The dictionary key to use. Default is None.
- edgeGroupsAny , optional
The input edge groups value. Default is [].
- edgeMinGroupAny , optional
The input edge min group value. Default is None.
- edgeMaxGroupAny , optional
The input edge max group value. Default is None.
- showEdgesAny , optional
If set to True, show edges are shown. Default is True.
- showEdgeLabelAny , optional
If set to True, show edge label are shown. Default is False.
- showEdgeLegendAny , optional
If set to True, show edge legend are shown. Default is False.
- colorScaleAny , optional
The Plotly color scale to use. Default is ‘viridis’.
- rendererAny , optional
The input renderer value. Default is None.
- widthAny , optional
The figure or output width. Default is 950.
- heightAny , optional
The figure or output height. Default is 500.
- xAxisAny , optional
The input x axis value. Default is False.
- yAxisAny , optional
The input y axis value. Default is False.
- zAxisAny , optional
The input z axis value. Default is False.
- axisSizeAny , optional
The input axis size value. Default is 1.
- backgroundColorAny , optional
The color value to use. Default is ‘rgba(0,0,0,0)’.
- marginLeftAny , optional
The input margin left value. Default is 0.
- marginRightAny , optional
The input margin right value. Default is 0.
- marginTopAny , optional
The input margin top value. Default is 20.
- marginBottomAny , optional
The input margin bottom value. Default is 0.
- cameraAny , optional
The input camera value. Default is [-1.25, -1.25, 1.25].
- centerAny , optional
The input center value. Default is [0, 0, 0].
- upAny , optional
The input up value. Default is [0, 0, 1].
- projectionAny , optional
The input projection value. 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
None
- static Size(graph: TGraph) int
Returns the number of active edges in the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- Returns
- int
The number of active edges.
- static SubGraphMatches(subGraph: TGraph, superGraph: TGraph, strict: bool = False, vertexKeys: Any = None, edgeKeys: Any = None, vertexKey: str = None, maxMatches: int = 25, timeLimit: float = 5, silent: bool = False) List[TGraph]
Returns subgraph matches of a pattern graph in a target graph.
- Parameters
- subGraph‘TGraph’
The input sub graph value.
- superGraph‘TGraph’
The input super graph value.
- strictbool , optional
The input strict value. Default is False.
- vertexKeysAny , optional
The input vertex keys value. Default is None.
- edgeKeysAny , optional
The input edge keys value. Default is None.
- vertexKeystr , optional
The vertex dictionary key to use. Default is None.
- maxMatchesint , optional
The input max matches value. Default is 25.
- timeLimitfloat , optional
The maximum time, in seconds, allowed for the search. Default is 5.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- List[TGraph]
The resulting TGraph, or None if the operation fails.
- static Subgraph(graph: TGraph, vertices: Iterable[int], induced: bool = True) Optional[TGraph]
Returns a subgraph containing the requested vertices.
- Parameters
- graph‘TGraph’
The input TGraph.
- verticesIterable[int]
The input vertices or vertex indices.
- inducedbool , optional
The input induced value. Default is True.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static SymmetricDifference(graphA: TGraph, graphB: TGraph, silent: bool = False, *, vertexKeys=None, edgeKeys=None, tolerance=None, useCentroid=False, matchBy=None, ambiguous='separate')
Returns the symmetric difference of two input TGraphs.
This implementation avoids unsafe index-based graph comparison. Vertices are matched only by a conservative stable identity key. Edges are included in the result only when their endpoint identities and edge direction do not appear in both graphs.
- Parameters
- graphATGraph
The first input TGraph.
- graphBTGraph
The second input TGraph.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static SyncSemantics(graph: TGraph, key: str = 'semantic_fingerprint', applyInferences: bool = False, returnResult: bool = False, silent: bool = False, **kwargs)
Updates semantic metadata and optionally applies inferred facts.
- static TTLString(graph: TGraph, includeVertices: bool = True, includeEdges: bool = True, includeDictionaries: bool = True, includeBOT: bool = True, namespacePrefix: str = 'inst', instanceNamespace: str = 'http://w3id.org/topologicpy/instance#', silent: bool = False) Optional[str]
Returns a Turtle TTL string representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- includeVerticesbool , optional
If set to True, include vertices are included. Default is True.
- includeEdgesbool , optional
If set to True, include edges are included. Default is True.
- includeDictionariesbool , optional
If set to True, dictionaries are included in the output. Default is True.
- includeBOTbool , optional
If set to True, include bot are included. Default is True.
- namespacePrefixstr , optional
The input namespace prefix value. Default is ‘inst’.
- instanceNamespacestr , optional
The input instance namespace value. Default is ‘http://w3id.org/topologicpy/instance#’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[str]
The resulting ttlstring string.
- static Tietze(radius: float = 0.5, height: float = 1) TGraph
Creates Tietze’s graph as a TGraph.
- Parameters
- radiusfloat , optional
Radius used for the generated circular embedding. Default is 0.5.
- heightfloat , optional
Vertical amplitude used for the generated embedding. Default is 1.
- Returns
- TGraph
The created Tietze graph.
- static ToPython(graph: TGraph, includeRepresentations: bool = False) Dict[str, Any]
Returns a Python dictionary representation of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- includeRepresentationsbool , optional
If set to True, stored representation objects are included in the output. Default is False.
- Returns
- Dict[str, Any]
The resulting to python dictionary.
- static TopologicEdge(graph: TGraph, edge: Union[int, Dict[str, Any]], transferVertexDictionaries: bool = True, transferEdgeDictionary: bool = True, useRepresentation: bool = True, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False)
Converts a TGraph edge to a Topologic edge.
- Parameters
- graph‘TGraph’
The input TGraph.
- edgeUnion[int, Dict[str, Any]]
The input edge, edge index, or edge record.
- transferVertexDictionariesbool , optional
If set to True, vertex dictionaries are transferred to created Topologic vertices. Default is True.
- transferEdgeDictionarybool , optional
If set to True, the edge dictionary is transferred to the created Topologic edge. Default is True.
- useRepresentationbool , optional
If set to True, stored representation objects are used when possible. Default is True.
- mantissaint , optional
The number of decimal places to round numeric results 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.Edge or None
The converted Topologic edge.
- static TopologicVertex(graph: TGraph, vertex: Union[int, Dict[str, Any]], transferDictionary: bool = True, useRepresentation: bool = True, mantissa: int = 6, silent: bool = False)
Converts a TGraph vertex to a Topologic vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- transferDictionarybool , optional
If set to True, the source dictionary is transferred to the created topology. Default is True.
- useRepresentationbool , optional
If set to True, stored representation objects are used when possible. Default is True.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Vertex or None
The converted Topologic vertex.
- static TopologicalDistance(graph: TGraph, vertexA: Any, vertexB: Any, mode: str = 'out', silent: bool = False) Optional[int]
Returns the topological distance between two vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexAAny
The first input vertex or vertex index.
- vertexBAny
The second input vertex or vertex index.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘out’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[int]
The resulting topological distance index or count.
- static Topology(graph: TGraph, includeVertices: bool = True, includeEdges: bool = True, useRepresentations: bool = True, segmentCurves: bool = True, tolerance: float = 0.0001, silent: bool = False) Optional[Any]
Returns a Topologic topology representation of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- includeVerticesbool , optional
If set to True, include vertices are included. Default is True.
- includeEdgesbool , optional
If set to True, include edges are included. Default is True.
- useRepresentationsbool , optional
If set to True, stored representation objects are used when possible. Default is True.
- segmentCurvesbool , optional
The input segment curves value. 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
- Optional[Any]
The resulting topology object or value.
- static TransferDictionariesToOriginators(graph, keys=None, originators=None, overwrite: bool = True, aggregation: str = 'error', returnReport: bool = False, silent: bool = False)
Transfers active-node dictionary values to their originating topologies.
keys may be a string/list, or None for non-structural dictionary fields. Existing topology fields are merged, not replaced. UUID and graph identity metadata are always protected. Multiple nodes targeting one topology may use error (default), first, last, sum, mean, min or max aggregation. With error, identical repeated values are allowed but conflicting values fail. Missing/ambiguous links and unsupported dictionary values fail preflight before any topology is modified. Supply originators to resolve imported UUIDs. Returns updated unique topologies, or a report when returnReport is True. Failed preflight returns None (or report with errors).
- static Tree(graph: TGraph, vertex=None, mode: str = 'all', silent: bool = False) Optional[TGraph]
Returns a tree derived from the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexint or dict , optional
The input vertex, vertex index, or vertex record. Default is None.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static Triples(graph: TGraph, **kwargs) List[Tuple[str, str, str]]
Returns relationship triples representing the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- **kwargsAny , optional
Additional keyword arguments.
- Returns
- List[Tuple[str, str, str]]
The resulting triples list.
- static TurtleFromTriples(triples: List[Tuple[Any, Any, Any]], namespaces: Optional[Dict[str, str]] = None, instanceNamespace: str = 'http://w3id.org/topologicpy/instance#', includeHeader: bool = True) str
Returns Turtle generated by the canonical ontology serializer.
- static Union(graphA: TGraph, graphB: TGraph, vertexKeys: list = None, edgeKeys: list = None, mantissa: int = 6, silent: bool = False, *, tolerance=None, useCentroid=False, matchBy=None, ambiguous='separate')
Returns the union of two input TGraphs.
Vertices from graphB are remapped into the output graph before graphB edges are added. Vertex identity is determined as follows:
If vertexKeys is not None, vertices are considered identical only when their dictionaries contain the same values at all supplied keys.
If vertexKeys is None, vertices are considered identical only when their representation coordinates match after rounding to mantissa.
Edge identity is determined as follows:
If edgeKeys is not None and an edge contains all supplied keys, the edge dictionary values at those keys define the edge identity.
Otherwise, edge identity falls back to the remapped source and destination vertex indices and edge direction.
- Parameters
- graphATGraph
The first input TGraph.
- graphBTGraph
The second input TGraph.
- vertexKeyslist , optional
A list of dictionary keys used to determine semantic vertex identity. If set to None, vertex identity falls back to matching x, y, z coordinates of the vertex representations. Default is None.
- edgeKeyslist , optional
A list of dictionary keys used to determine semantic edge identity. If set to None, edge identity falls back to source/destination vertex indices and direction after graphB vertices have been remapped. Default is None.
- mantissaint , optional
The number of decimal places to use when matching coordinates. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- static ValidateOntology(graph: TGraph, requireClass: bool = True, requireVertexClasses: bool = False, requireEdgeClasses: bool = False, requireLabels: bool = False, checkClassKnown: bool = True, checkCategory: bool = True, silent: bool = False) Dict[str, Any]
Validates ontology metadata against the canonical ontology.
- static ValidateTTLString(ttlString: str, silent: bool = False) Dict[str, Any]
Validates a Turtle TTL string.
- Parameters
- ttlStringstr
The input ttl string value.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Dict[str, Any]
The resulting validate ttlstring dictionary.
- static Vertex(graph: TGraph, index: int, copy: bool = False, active: bool = False, asTopologic: bool = False, silent: bool = False)
Returns the vertex record at the input vertex index.
- Parameters
- graphTGraph
The input TGraph.
- indexint
The desired vertex index.
- copybool , optional
If True, a shallow copy of the record is returned, with a copied dictionary. If False, the live internal record is returned and can be modified in-place. Default is False.
- activebool , optional
If True, the vertex must be active. If False, inactive vertices are also accepted. Default is False.
- asTopologicbool , optional
If set to True, records are returned as Topologic objects when possible. Default is False.
- silentbool , optional
If True, error messages are suppressed. Default is False.
- Returns
- dict or None
The vertex record.
- static VertexByKeyValue(graph: TGraph, key: str = None, value: Any = None, copy: bool = False, active: bool = False, asTopologic: bool = False, silent: bool = False) Optional[Dict[str, Any]]
Returns the first active vertex whose dictionary contains the requested key-value pair.
- Parameters
- graph‘TGraph’
The input TGraph.
- keystr , optional
The dictionary key to use. Default is None.
- valueAny , optional
The input value value. Default is None.
- copybool , optional
If True, a shallow copy of the record is returned, with a copied dictionary. If False, the live internal record is returned and can be modified in-place. Default is False.
- activebool , optional
If True, the vertex must be active. If False, inactive vertices are also accepted. Default is False.
- asTopologicbool , optional
If set to True, records are returned as Topologic objects when possible. Default is False.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[Dict[str, Any]]
The resulting vertex by key value dictionary.
- static VertexConnectivity(graph: TGraph, source: Any, target: Any, snapEndpoints: bool = True, tolerance: float = 1e-12, silent: bool = False) int
Returns the local vertex connectivity between source and target.
This is the maximum number of internally vertex-disjoint source-target paths. The source and target themselves may be shared by all paths.
- Parameters
- graphTGraph
The input TGraph.
- sourceAny
The source vertex index or vertex-like input.
- targetAny
The target vertex index or vertex-like input.
- snapEndpointsbool , optional
If True, unresolved vertex-like inputs are snapped to the nearest active TGraph vertex. Default is True.
- tolerancefloat , optional
Numerical tolerance used by the maximum-flow calculation. Default is 1e-12.
- silentbool , optional
If True, suppresses error messages. Default is False.
- Returns
- int
The local vertex connectivity. Returns 0 if the request is invalid or no source-target path exists.
- static VertexDegree(graph: TGraph, vertex: Any, mode: str = 'all', silent: bool = False, *, weightKey=None)
Returns the degree of the input vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexAny
The input vertex, vertex index, or vertex record.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[int]
The resulting vertex degree index or count.
- weightKey requests weighted degree (strength); missing weights count as one.
- Self-loops count twice in total/undirected degree and once per directed in/out degree.
- VertexDictionary(index: Any, copy: bool = True) Dict[str, Any]
Returns the dictionary of a vertex.
- Parameters
- indexint or dict
The vertex index or vertex record.
- copybool , optional
If set to True, a copy of the dictionary is returned. If set to False, the live dictionary is returned and may be modified in-place. Default is True.
- Returns
- dict
The vertex dictionary.
- static VertexDictionaryStatic(graph: TGraph, index: Any, copy: bool = True) Dict[str, Any]
Returns the dictionary of a vertex in the input TGraph.
- Parameters
- graphTGraph
The input TGraph.
- indexint or dict
The vertex index or vertex record.
- copybool , optional
If set to True, a copy of the dictionary is returned. If False, the live dictionary is returned. Default is True.
- Returns
- dict
The vertex dictionary.
- static VertexIndex(graph: TGraph, vertex: Union[int, Dict[str, Any]]) Optional[int]
Returns the index of the input vertex.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexUnion[int, Dict[str, Any]]
The input vertex, vertex index, or vertex record.
- Returns
- Optional[int]
The resulting vertex index index or count.
- static VertexOriginator(graph, vertex, originators=None, silent: bool = False)
Returns a node’s source object, or resolves it by UUID against a list.
An explicit originators list is authoritative (useful after JSON import). Duplicate UUIDs on distinct supplied objects are rejected; coordinates and graph indices are never used to guess identity. Missing links return None. Successful resolution restores the live reference on the record.
- VertexValue(vertex: Any, key: str, default: Any = None) Any
Returns a dictionary value from a vertex.
- Parameters
- vertexint or dict
The vertex index or vertex record.
- keystr
The dictionary key.
- defaultAny , optional
The value returned if the key is not found. Default is None.
- Returns
- Any
The requested value.
- static Vertices(graph: TGraph, copy: bool = False, asTopologic: bool = False, useRepresentation: bool = True, active: bool = True, mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False, *, sortBy=None, reverse=False)
Returns the vertices of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- copybool , optional
If True, a shallow copy of the record is returned, with a copied dictionary. If False, the live internal record is returned and can be modified in-place. Default is False.
- asTopologicbool , optional
If set to True, records are returned as Topologic objects when possible. Default is False.
- useRepresentationbool , optional
If set to True, stored representation objects are used when possible. Default is True.
- activebool , optional
If set to True, only active records are considered. Default is True.
- mantissaint , optional
The number of decimal places to round numeric results 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 requested vertex records or Topologic vertices.
- sortBy selects one dictionary key or a sequence of keys; reverse sorts descending.
- Missing values sort last. Sorting changes the returned view, never stored indices.
- static VerticesCSVString(graph: TGraph, includeInactive: bool = False) str
Returns a lightweight CSV string of TGraph vertex records.
This method is intended for TGraph-native record serialisation. For PyTorch/PyG-ready datasets, use ByCSVPath and ExportToCSV.
- Parameters
- graphTGraph
The input TGraph.
- includeInactivebool , optional
If set to True, inactive vertices are included. Default is False.
- Returns
- str
The vertices CSV string.
- static VisibilityGraph(face: Any, vertices: Optional[List[Any]] = None, obstacles: Optional[List[Any]] = None, bidirectional: bool = True, maxDistance: Optional[float] = None, maxNeighbors: Optional[int] = None, includeBoundaryVertices: bool = True, leafSize: int = 24, allowBoundaryPaths: bool = True, trim: bool = False, approximateMaxNeighbors: bool = False, neighborCandidateFactor: int = 8, tolerance: float = 0.0001, silent: bool = False, storeEdgeRepresentations: bool = True, ontology: bool = True, useNumba: bool = False, *, maxCandidatePairs: Optional[int] = None, maxEdges: Optional[int] = None) Optional[TGraph]
Returns a fast visibility graph derived from the input planar face.
This implementation is designed for navigation visibility graphs and avoids Topologic boolean operations inside the main visibility loop. It uses an angular event sweep for full graphs and an exact distance-ordered early-stop strategy for sparse maxNeighbors graphs.
- Parameters
- faceAny
The input planar face defining the navigable region.
- verticesOptional[List[Any]] , optional
The input vertices or vertex indices. If set to None, face boundary vertices are used. Default is None.
- obstaclesOptional[List[Any]] , optional
The input obstacle topologies. Their edges are treated as visibility blockers. Default is None.
- bidirectionalbool , optional
If set to True, an undirected graph is returned. If set to False, a directed graph is returned with both directions explicitly inserted for every accepted visibility pair. Default is True.
- maxDistanceOptional[float] , optional
Optional maximum visibility edge length. Candidate pairs longer than this value are skipped. Default is None.
- maxNeighborsOptional[int] , optional
Optional maximum number of visible neighbours retained per source vertex. If None, the full visibility graph is built. Default is None.
- includeBoundaryVerticesbool , optional
If set to True, face and obstacle boundary vertices are added to the candidate visibility vertices. This is usually desirable for navigation because shortest paths around obstacles need obstacle corner vertices. Default is True.
- leafSizeint , optional
Compatibility parameter used as the direct-check threshold. When the number of source-relevant blockers is at or below this value, direct exact blocker checks are faster than constructing angular sweep events. Default is 24.
- allowBoundaryPathsbool , optional
If set to True, collinear overlap with an individual face/obstacle boundary segment is allowed. Other incident boundary segments can still block the sightline. This option does not permit passage through a boundary corner in the interior of a sightline. Default is True.
- trimbool , optional
If set to True, visibility edges whose interiors leave the host face are rejected. This is useful for concave faces or faces with holes, where two vertices may see each other geometrically but the connecting segment lies partly outside the navigable face. Default is False.
- approximateMaxNeighborsbool , optional
If set to True and maxNeighbors is not None, only the nearest maxNeighbors*neighborCandidateFactor candidate vertices are tested per source. This is faster but no longer builds the exact sparse nearest-visible-neighbour graph. Default is False.
- neighborCandidateFactorint , optional
Candidate multiplier used when approximateMaxNeighbors is True. Default is 8.
- tolerancefloat , optional
The desired geometric tolerance. Default is 0.0001.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- storeEdgeRepresentationsbool , optional
If set to True, a Topologic Edge representation is created and stored for every visibility edge. If False, visibility edges remain purely logical and can be reconstructed later from their endpoint vertex representations. Disabling this can substantially reduce construction time and memory for dense visibility graphs. Default is True.
- ontologybool , optional
If set to True, ontology metadata is annotated on the graph, vertices, and edges before return. Set to False to avoid this final annotation pass when maximum construction speed is required. Default is True.
- maxCandidatePairs, maxEdgesOptional[int], keyword-only
Positive resource budgets, or None for no budget. Candidate pairs are counted before geometric visibility tests (directed source searches count both orientations). maxEdges counts output edges, including both orientations when bidirectional=False. Exceeding a budget raises ValueError; results are never silently truncated.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.
- useNumbabool , optional
If True, use an optional single-core Numba kernel for full visibility searches. NumPy and Numba must be installed. The first call may compile the kernel; later calls reuse its cached code. Default is False. If the accelerator cannot be loaded or compiled, use the Python implementation. Positive maxNeighbors searches retain the Python implementation.
Notes
Corner-contact convention: a sightline is blocked when a face or obstacle boundary-segment endpoint lies in its interior, including a purely tangential touch that does not enter the obstacle. Contacts coinciding with a sightline’s own endpoints are not rejected by this corner rule, although other visibility checks still apply. Geometric comparisons use the supplied tolerance.
This conservative rule applies even with trim=False and allowBoundaryPaths=True: wall-blocking checks are independent of host- face trimming. Allowing collinear boundary overlap does not disable corner-contact blocking by incident segments.
Complete visibility-link comparisons against DepthmapX 0.9.1 agreed for spacing-1 grids in square rooms containing either a square or a diamond hole, using identical sample coordinates. Both rejected tangential corner contacts and crossings into the hole through a vertex. These controlled cases do not establish parity for all geometries, grid alignments, tolerances or DepthmapX versions.
- static WLFeatures(graph: TGraph, key: str = None, iterations: int = 2, labelKey: str = None, silent: bool = False) Optional[Dict[Any, int]]
Returns Weisfeiler-Lehman feature counts for the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- keystr , optional
The dictionary key to use. Default is None.
- iterationsint , optional
The input iterations value. Default is 2.
- labelKeystr , optional
The dictionary key to use. Default is None.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[Dict[Any, int]]
The resulting wlfeatures dictionary.
- static WLKernel(graphA: TGraph, graphB: TGraph, key: str = None, iterations: int = 2, labelKey: str = None, normalize: bool = True, mantissa: int = 6, silent: bool = False) Optional[float]
Returns a Weisfeiler-Lehman kernel similarity score between two input TGraphs.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’
The second input TGraph.
- keystr , optional
The dictionary key to use. Default is None.
- iterationsint , optional
The input iterations value. Default is 2.
- labelKeystr , optional
The dictionary key to use. Default is None.
- normalizebool , optional
If set to True, returned values are normalized. Default is True.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[float]
The resulting wlkernel value.
- static WarmUpAcceleration(graph: TGraph, mode: str = 'all', useNumba: bool = True) Dict[str, Any]
Warms up optional acceleration paths used by TGraph algorithms.
- Parameters
- graph‘TGraph’
The input TGraph.
- modestr , optional
The traversal or adjacency mode. Valid values are typically “out”, “in”, or “all”. Default is ‘all’.
- useNumbabool , optional
If set to True, Numba acceleration is used when available. Default is True.
- Returns
- Dict[str, Any]
The resulting warm up acceleration dictionary.
- static WeightedJaccardSimilarity(graphA: TGraph, graphB: TGraph = None, vertexA: Any = None, vertexB: Any = None, vertexIDKey: str = 'id', edgeWeightKey: str = None, weightKey: str = None, key: str = None, mantissa: int = 6, silent: bool = False) Optional[float]
Returns a weighted Jaccard similarity score between two input TGraphs.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’ , optional
The second input TGraph. Default is None.
- vertexAAny , optional
The first input vertex or vertex index. Default is None.
- vertexBAny , optional
The second input vertex or vertex index. Default is None.
- vertexIDKeystr , optional
The dictionary key to use. Default is ‘id’.
- edgeWeightKeystr , optional
The dictionary key to use. Default is None.
- weightKeystr , optional
The edge dictionary key to use as a weight. Default is None.
- keystr , optional
The dictionary key to use. Default is None.
- mantissaint , optional
The number of decimal places to round numeric results to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[float]
The resulting weighted jaccard similarity value.
- static WikiString(graph: TGraph, vertexKey: str = 'id', vertexLabelKey: str = 'label', vertexTypeKey: str = 'type', edgeKey: str = 'predicate', titleKey: str = None, includeDictionaries: bool = True, includeBacklinks: bool = True, tolerance: float = 0.0001, silent: bool = False) str
Returns a Wiki-compatible string representation of the input TGraph.
- Parameters
- graph‘TGraph’
The input TGraph.
- vertexKeystr , optional
The vertex dictionary key to use. Default is ‘id’.
- vertexLabelKeystr , optional
The dictionary key to use. Default is ‘label’.
- vertexTypeKeystr , optional
The dictionary key to use. Default is ‘type’.
- edgeKeystr , optional
The edge dictionary key to use. Default is ‘predicate’.
- titleKeystr , optional
The dictionary key to use. Default is None.
- includeDictionariesbool , optional
If set to True, dictionaries are included in the output. Default is True.
- includeBacklinksbool , optional
If set to True, include backlinks are included. 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
- str
The resulting wiki string string.
- static WireByPath(graph: TGraph, path: list, transferVertexDictionaries: bool = False, transferEdgeDictionaries: bool = False, tolerance: float = 0.0001, silent: bool = False)
Converts an ordered TGraph path into a Topologic Wire.
The path direction is preserved: the resulting wire starts at path[0] and ends at path[-1]. Stored edge representations are reused whenever possible. If a stored edge is oriented opposite to the path traversal, the method first attempts a kernel-native reversal so curved and NURBS geometry is preserved.
- Parameters
- graphTGraph
The input TGraph.
- pathlist
The ordered path of TGraph vertex indices or vertex records, typically returned by TGraph.ShortestPath.
- transferVertexDictionariesbool , optional
If set to True, graph vertex dictionaries are transferred to the corresponding Topologic vertices. Default is False.
- transferEdgeDictionariesbool , optional
If set to True, graph edge dictionaries are transferred to the corresponding Topologic edges. 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.Wire or None
The resulting directed Topologic Wire, or None if it cannot be created.
- static XOR(graphA: TGraph, graphB: TGraph, silent: bool = False, *, vertexKeys=None, edgeKeys=None, tolerance=None, useCentroid=False, matchBy=None, ambiguous='separate')
Returns the symmetric difference of two input TGraphs.
- Parameters
- graphA‘TGraph’
The first input TGraph.
- graphB‘TGraph’
The second input TGraph.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- Optional[TGraph]
The resulting TGraph, or None if the operation fails.