topologicpy 0.8.23__py3-none-any.whl → 0.8.24__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topologicpy/Graph.py +566 -34
- topologicpy/version.py +1 -1
- {topologicpy-0.8.23.dist-info → topologicpy-0.8.24.dist-info}/METADATA +1 -1
- {topologicpy-0.8.23.dist-info → topologicpy-0.8.24.dist-info}/RECORD +7 -7
- {topologicpy-0.8.23.dist-info → topologicpy-0.8.24.dist-info}/WHEEL +1 -1
- {topologicpy-0.8.23.dist-info → topologicpy-0.8.24.dist-info}/licenses/LICENSE +0 -0
- {topologicpy-0.8.23.dist-info → topologicpy-0.8.24.dist-info}/top_level.txt +0 -0
topologicpy/Graph.py
CHANGED
@@ -65,6 +65,20 @@ except:
|
|
65
65
|
except:
|
66
66
|
warnings.warn("Graph - Error: Could not import tqdm.")
|
67
67
|
|
68
|
+
try:
|
69
|
+
from graphviz import Digraph
|
70
|
+
except:
|
71
|
+
print("Graph - Installing required graphviz library.")
|
72
|
+
try:
|
73
|
+
os.system("pip install graphviz")
|
74
|
+
except:
|
75
|
+
os.system("pip install graphviz --user")
|
76
|
+
try:
|
77
|
+
from graphviz import Digraph
|
78
|
+
print("Graph - graphviz library installed correctly.")
|
79
|
+
except:
|
80
|
+
warnings.warn("Graph - Error: Could not import graphviz.")
|
81
|
+
|
68
82
|
GraphQueueItem = namedtuple('GraphQueueItem', ['edges'])
|
69
83
|
|
70
84
|
class WorkerProcessPool(object):
|
@@ -1417,7 +1431,7 @@ class Graph:
|
|
1417
1431
|
from topologicpy.Helper import Helper
|
1418
1432
|
|
1419
1433
|
if weightKey:
|
1420
|
-
if "len" in weightKey.lower() or "dis" in
|
1434
|
+
if "len" in weightKey.lower() or "dis" in weightKey.lower():
|
1421
1435
|
weightKey = "length"
|
1422
1436
|
nx_graph = Graph.NetworkXGraph(graph)
|
1423
1437
|
if "vert" in method.lower():
|
@@ -5566,7 +5580,7 @@ class Graph:
|
|
5566
5580
|
|
5567
5581
|
"""
|
5568
5582
|
import numpy as np
|
5569
|
-
adj_matrix = Graph.AdjacencyMatrix(
|
5583
|
+
adj_matrix = Graph.AdjacencyMatrix(graph)
|
5570
5584
|
np_adj_matrix = np.array(adj_matrix)
|
5571
5585
|
degree_matrix = np.diag(np_adj_matrix.sum(axis=1))
|
5572
5586
|
return degree_matrix.tolist()
|
@@ -6125,7 +6139,7 @@ class Graph:
|
|
6125
6139
|
format = "turtle"
|
6126
6140
|
ext = ".ttl"
|
6127
6141
|
n = len(ext)
|
6128
|
-
# Make sure the file extension is .
|
6142
|
+
# Make sure the file extension is .bot
|
6129
6143
|
ext = path[len(path)-n:len(path)]
|
6130
6144
|
if ext.lower() != ext:
|
6131
6145
|
path = path+ext
|
@@ -6674,7 +6688,7 @@ class Graph:
|
|
6674
6688
|
if not isinstance(path, str):
|
6675
6689
|
print("Graph.ExportToGEXF - Error: the input path parameter is not a valid string. Returning None.")
|
6676
6690
|
return None
|
6677
|
-
# Make sure the file extension is .
|
6691
|
+
# Make sure the file extension is .gexf
|
6678
6692
|
ext = path[len(path)-5:len(path)]
|
6679
6693
|
if ext.lower() != ".gexf":
|
6680
6694
|
path = path+".gexf"
|
@@ -6869,6 +6883,243 @@ class Graph:
|
|
6869
6883
|
create_gexf_file(nodes, edges, defaultEdgeType, node_attributes, edge_attributes, path)
|
6870
6884
|
return True
|
6871
6885
|
|
6886
|
+
@staticmethod
|
6887
|
+
def ExportToGraphVizGraph(graph,
|
6888
|
+
path,
|
6889
|
+
device = 'svg_inline', deviceKey=None,
|
6890
|
+
scale = 1, scaleKey=None,
|
6891
|
+
directed=False, directedKey=None,
|
6892
|
+
layout = 'dot', # or circo fdp neato nop nop1 nop2 osage patchwork sfdp twopi
|
6893
|
+
layoutKey=None,
|
6894
|
+
rankDir='TB', rankDirKey=None, # or LR, RL, BT
|
6895
|
+
bgColor='white', bgColorKey=None,
|
6896
|
+
fontName='Arial', fontNameKey=None,
|
6897
|
+
fontSize= 12, fontSizeKey=None,
|
6898
|
+
vertexSep= 0.5, vertexSepKey=None,
|
6899
|
+
rankSep= 0.5, rankSepKey=None,
|
6900
|
+
splines='True', splinesKey=None,
|
6901
|
+
showGraphLabel = False,
|
6902
|
+
graphLabel='', graphLabelKey=None,
|
6903
|
+
graphLabelLoc='t', graphLabelLocKey=None,
|
6904
|
+
showVertexLabel = False,
|
6905
|
+
vertexLabelPrefix='' , vertexLabelKey=None,
|
6906
|
+
vertexWidth=0.5, vertexWidthKey=None,
|
6907
|
+
vertexHeight=0.5, vertexHeightKey=None,
|
6908
|
+
vertexFixedSize=False, vertexFixedSizeKey=None,
|
6909
|
+
vertexShape='circle', vertexShapeKey=None,
|
6910
|
+
vertexStyle='filled', vertexStyleKey=None,
|
6911
|
+
vertexFillColor='lightgray', vertexFillColorKey=None,
|
6912
|
+
vertexColor='black', vertexColorKey=None,
|
6913
|
+
vertexFontColor='black', vertexFontColorKey=None,
|
6914
|
+
showEdgeLabel = False,
|
6915
|
+
edgeLabelPrefix='', edgeLabelKey=None,
|
6916
|
+
edgeColor='black', edgeColorKey=None,
|
6917
|
+
edgeWidth=1, edgeWidthKey=None,
|
6918
|
+
edgeStyle='solid', edgeStyleKey=None,
|
6919
|
+
edgeArrowhead='normal', edgeArrowheadKey=None,
|
6920
|
+
edgeFontColor='black', edgeFontColorKey=None,
|
6921
|
+
overwrite=False,
|
6922
|
+
silent=False):
|
6923
|
+
"""
|
6924
|
+
Exports the input graph to a GraphViz `.gv` (dot) file.
|
6925
|
+
|
6926
|
+
Parameters
|
6927
|
+
----------
|
6928
|
+
graph : topologic_core.Graph
|
6929
|
+
The input graph.
|
6930
|
+
path : str
|
6931
|
+
The path to the output file (e.g., "output.gv").
|
6932
|
+
device : str, optional
|
6933
|
+
The output format device, such as 'svg_inline', 'pdf', or 'png'. The default is 'svg_inline'.
|
6934
|
+
deviceKey : str, optional
|
6935
|
+
Dictionary key to override the `device` value. Default is None.
|
6936
|
+
scale : float, optional
|
6937
|
+
Global scaling factor. Default is 1.
|
6938
|
+
scaleKey : str, optional
|
6939
|
+
Dictionary key to override the `scale` per-graph. Default is None.
|
6940
|
+
directed : bool, optional
|
6941
|
+
Whether to treat the graph as directed. Default is False.
|
6942
|
+
directedKey : str, optional
|
6943
|
+
Dictionary key to override the `directed` flag per-graph. Default is None.
|
6944
|
+
layout : str, optional
|
6945
|
+
Layout engine to use. Options include 'dot', 'circo', 'fdp', 'neato', 'osage', 'sfdp', etc. Default is 'dot'.
|
6946
|
+
layoutKey : str, optional
|
6947
|
+
Dictionary key to override the `layout` per-graph. Default is None.
|
6948
|
+
rankDir : str, optional
|
6949
|
+
Direction of graph ranking. Options: 'TB' (top-bottom), 'LR' (left-right), 'RL', 'BT'. Default is 'TB'.
|
6950
|
+
rankDirKey : str, optional
|
6951
|
+
Dictionary key to override `rankDir` per-graph. Default is None.
|
6952
|
+
bgColor : str, optional
|
6953
|
+
Background color. Default is 'white'.
|
6954
|
+
bgColorKey : str, optional
|
6955
|
+
Dictionary key to override `bgColor`. Default is None.
|
6956
|
+
fontName : str, optional
|
6957
|
+
Name of the font to use for all text. Default is 'Arial'.
|
6958
|
+
fontNameKey : str, optional
|
6959
|
+
Dictionary key to override `fontName`. Default is None.
|
6960
|
+
fontSize : int or float, optional
|
6961
|
+
Size of font in points. Default is 12.
|
6962
|
+
fontSizeKey : str, optional
|
6963
|
+
Dictionary key to override `fontSize`. Default is None.
|
6964
|
+
vertexSep : float, optional
|
6965
|
+
Minimum separation between vertices. Default is 0.5.
|
6966
|
+
vertexSepKey : str, optional
|
6967
|
+
Dictionary key to override `vertexSep`. Default is None.
|
6968
|
+
rankSep : float, optional
|
6969
|
+
Separation between ranks. Default is 0.5.
|
6970
|
+
rankSepKey : str, optional
|
6971
|
+
Dictionary key to override `rankSep`. Default is None.
|
6972
|
+
splines : str, optional
|
6973
|
+
Whether to use spline edges. Can be 'true', 'false', or 'polyline'. Default is 'True'.
|
6974
|
+
splinesKey : str, optional
|
6975
|
+
Dictionary key to override `splines`. Default is None.
|
6976
|
+
showGraphLabel : bool, optional
|
6977
|
+
Whether to show a label for the whole graph. Default is False.
|
6978
|
+
graphLabel : str, optional
|
6979
|
+
Text for the graph label. Default is an empty string.
|
6980
|
+
graphLabelKey : str, optional
|
6981
|
+
Dictionary key to override `graphLabel`. Default is None.
|
6982
|
+
graphLabelLoc : str, optional
|
6983
|
+
Position of the graph label: 't' (top), 'b' (bottom), 'c' (center). Default is 't'.
|
6984
|
+
graphLabelLocKey : str, optional
|
6985
|
+
Dictionary key to override `graphLabelLoc`. Default is None.
|
6986
|
+
showVertexLabel : bool, optional
|
6987
|
+
Whether to display vertex labels. Default is False.
|
6988
|
+
vertexLabelPrefix : str, optional
|
6989
|
+
Text prefix for vertex labels. Default is empty string.
|
6990
|
+
vertexLabelKey : str, optional
|
6991
|
+
Dictionary key used to retrieve label text from vertex dictionary. Default is None.
|
6992
|
+
vertexWidth : float, optional
|
6993
|
+
Width of each vertex. Default is 0.5.
|
6994
|
+
vertexWidthKey : str, optional
|
6995
|
+
Dictionary key to override `vertexWidth`. Default is None.
|
6996
|
+
vertexHeight : float, optional
|
6997
|
+
Height of each vertex. Default is 0.5.
|
6998
|
+
vertexHeightKey : str, optional
|
6999
|
+
Dictionary key to override `vertexHeight`. Default is None.
|
7000
|
+
vertexFixedSize : bool, optional
|
7001
|
+
Whether vertices should be fixed in size. Default is False.
|
7002
|
+
vertexFixedSizeKey : str, optional
|
7003
|
+
Dictionary key to override `vertexFixedSize`. Default is None.
|
7004
|
+
vertexShape : str, optional
|
7005
|
+
Shape of the vertex ('circle', 'ellipse', 'box', etc.). Default is 'circle'.
|
7006
|
+
vertexShapeKey : str, optional
|
7007
|
+
Dictionary key to override `vertexShape`. Default is None.
|
7008
|
+
vertexStyle : str, optional
|
7009
|
+
Style of vertex (e.g., 'filled', 'dashed'). Default is 'filled'.
|
7010
|
+
vertexStyleKey : str, optional
|
7011
|
+
Dictionary key to override `vertexStyle`. Default is None.
|
7012
|
+
vertexFillColor : str, optional
|
7013
|
+
Fill color for vertices. Default is 'lightgray'.
|
7014
|
+
vertexFillColorKey : str, optional
|
7015
|
+
Dictionary key to override `vertexFillColor`. Default is None.
|
7016
|
+
vertexColor : str, optional
|
7017
|
+
Border color for vertices. Default is 'black'.
|
7018
|
+
vertexColorKey : str, optional
|
7019
|
+
Dictionary key to override `vertexColor`. Default is None.
|
7020
|
+
vertexFontColor : str, optional
|
7021
|
+
Font color for vertex labels. Default is 'black'.
|
7022
|
+
vertexFontColorKey : str, optional
|
7023
|
+
Dictionary key to override `vertexFontColor`. Default is None.
|
7024
|
+
showEdgeLabel : bool, optional
|
7025
|
+
Whether to display edge labels. Default is False.
|
7026
|
+
edgeLabelPrefix : str, optional
|
7027
|
+
Text prefix for edge labels. Default is empty string.
|
7028
|
+
edgeLabelKey : str, optional
|
7029
|
+
Dictionary key used to retrieve label text from edge dictionary. Default is None.
|
7030
|
+
edgeColor : str, optional
|
7031
|
+
Color of edges. Default is 'black'.
|
7032
|
+
edgeColorKey : str, optional
|
7033
|
+
Dictionary key to override `edgeColor`. Default is None.
|
7034
|
+
edgeWidth : float, optional
|
7035
|
+
Width (thickness) of edges. Default is 1.
|
7036
|
+
edgeWidthKey : str, optional
|
7037
|
+
Dictionary key to override `edgeWidth`. Default is None.
|
7038
|
+
edgeStyle : str, optional
|
7039
|
+
Style of the edge line (e.g., 'solid', 'dashed'). Default is 'solid'.
|
7040
|
+
edgeStyleKey : str, optional
|
7041
|
+
Dictionary key to override `edgeStyle`. Default is None.
|
7042
|
+
edgeArrowhead : str, optional
|
7043
|
+
Arrowhead style for directed edges. Default is 'normal'.
|
7044
|
+
edgeArrowheadKey : str, optional
|
7045
|
+
Dictionary key to override `edgeArrowhead`. Default is None.
|
7046
|
+
edgeFontColor : str, optional
|
7047
|
+
Font color for edge labels. Default is 'black'.
|
7048
|
+
edgeFontColorKey : str, optional
|
7049
|
+
Dictionary key to override `edgeFontColor`. Default is None.
|
7050
|
+
overwrite : bool, optional
|
7051
|
+
If True, overwrites existing files at the given path. Default is False.
|
7052
|
+
silent : bool, optional
|
7053
|
+
If True, suppresses console output. Default is False.
|
7054
|
+
|
7055
|
+
Returns
|
7056
|
+
-------
|
7057
|
+
bool
|
7058
|
+
True if the graph was successfully exported. False otherwise.
|
7059
|
+
"""
|
7060
|
+
|
7061
|
+
from topologicpy.Topology import Topology
|
7062
|
+
from os.path import exists
|
7063
|
+
dot = Graph.GraphVizGraph(
|
7064
|
+
graph,
|
7065
|
+
device = device, deviceKey = deviceKey,
|
7066
|
+
scale = scale, scaleKey = scaleKey,
|
7067
|
+
directed = directed, directedKey = directedKey,
|
7068
|
+
layout = layout,
|
7069
|
+
layoutKey = layoutKey,
|
7070
|
+
rankDir= rankDir, rankDirKey = rankDirKey,
|
7071
|
+
bgColor=bgColor, bgColorKey=bgColorKey,
|
7072
|
+
fontName=fontName, fontNameKey=fontNameKey,
|
7073
|
+
fontSize= fontSize, fontSizeKey=fontSizeKey,
|
7074
|
+
vertexSep= vertexSep, vertexSepKey=vertexSepKey,
|
7075
|
+
rankSep= rankSep, rankSepKey=rankSepKey,
|
7076
|
+
splines=splines, splinesKey=splinesKey,
|
7077
|
+
showGraphLabel = showGraphLabel,
|
7078
|
+
graphLabel=graphLabel, graphLabelKey=graphLabelKey,
|
7079
|
+
graphLabelLoc=graphLabelLoc, graphLabelLocKey=graphLabelLocKey,
|
7080
|
+
|
7081
|
+
showVertexLabel = showVertexLabel,
|
7082
|
+
vertexLabelPrefix=vertexLabelPrefix , vertexLabelKey=vertexLabelKey,
|
7083
|
+
vertexWidth=vertexWidth, vertexWidthKey=vertexWidthKey,
|
7084
|
+
vertexHeight=vertexHeight, vertexHeightKey=vertexHeightKey,
|
7085
|
+
vertexFixedSize=vertexFixedSize, vertexFixedSizeKey=vertexFixedSizeKey,
|
7086
|
+
vertexShape=vertexShape, vertexShapeKey=vertexShapeKey,
|
7087
|
+
vertexStyle=vertexStyle, vertexStyleKey=vertexStyleKey,
|
7088
|
+
vertexFillColor=vertexFillColor, vertexFillColorKey=vertexFillColorKey,
|
7089
|
+
vertexColor=vertexColor, vertexColorKey=vertexColorKey,
|
7090
|
+
vertexFontColor=vertexFontColor, vertexFontColorKey=vertexFontColorKey,
|
7091
|
+
|
7092
|
+
showEdgeLabel = showEdgeLabel,
|
7093
|
+
edgeLabelPrefix=edgeLabelPrefix, edgeLabelKey=edgeLabelKey,
|
7094
|
+
edgeColor=edgeColor, edgeColorKey=edgeColorKey,
|
7095
|
+
edgeWidth=edgeWidth, edgeWidthKey=edgeWidthKey,
|
7096
|
+
edgeStyle=edgeStyle, edgeStyleKey=edgeStyleKey,
|
7097
|
+
edgeArrowhead=edgeArrowhead, edgeArrowheadKey=edgeArrowheadKey,
|
7098
|
+
edgeFontColor=edgeFontColor, edgeFontColorKey=edgeFontColorKey,
|
7099
|
+
silent=silent)
|
7100
|
+
|
7101
|
+
if not Topology.IsInstance(graph, "Graph"):
|
7102
|
+
if not silent:
|
7103
|
+
print("Graph.ExportToGraphVizGraph - Error: the input graph parameter is not a valid graph. Returning None.")
|
7104
|
+
return None
|
7105
|
+
if not isinstance(path, str):
|
7106
|
+
if not silent:
|
7107
|
+
print("Graph.ExportToGraphVizGraph - Error: the input path parameter is not a valid string. Returning None.")
|
7108
|
+
return None
|
7109
|
+
# Make sure the file extension is .gv
|
7110
|
+
ext = path[len(path)-3:len(path)]
|
7111
|
+
if ext.lower() != ".gv":
|
7112
|
+
path = path+".gv"
|
7113
|
+
if not overwrite and exists(path):
|
7114
|
+
if not silent:
|
7115
|
+
print("Graph.ExportToGraphVizGraph - Error: a file already exists at the specified path and overwrite is set to False. Returning None.")
|
7116
|
+
return None
|
7117
|
+
try:
|
7118
|
+
dot.save(filename=path)
|
7119
|
+
return True
|
7120
|
+
except:
|
7121
|
+
return False
|
7122
|
+
|
6872
7123
|
@staticmethod
|
6873
7124
|
def ExportToJSON(graph, path, verticesKey="vertices", edgesKey="edges", vertexLabelKey="", edgeLabelKey="", xKey="x", yKey="y", zKey="z", indent=4, sortKeys=False, mantissa=6, overwrite=False):
|
6874
7125
|
"""
|
@@ -8187,6 +8438,287 @@ class Graph:
|
|
8187
8438
|
adjacency_matrix = Graph.AdjacencyMatrix(graph)
|
8188
8439
|
return global_clustering_coefficient(adjacency_matrix)
|
8189
8440
|
|
8441
|
+
@staticmethod
|
8442
|
+
def GraphVizGraph(
|
8443
|
+
graph,
|
8444
|
+
device = 'svg_inline', deviceKey=None,
|
8445
|
+
scale = 1, scaleKey=None,
|
8446
|
+
directed=False, directedKey=None,
|
8447
|
+
layout = 'dot', # or circo fdp neato nop nop1 nop2 osage patchwork sfdp twopi
|
8448
|
+
layoutKey=None,
|
8449
|
+
rankDir='TB', rankDirKey=None, # or LR, RL, BT
|
8450
|
+
bgColor='white', bgColorKey=None,
|
8451
|
+
fontName='Arial', fontNameKey=None,
|
8452
|
+
fontSize= 12, fontSizeKey=None,
|
8453
|
+
vertexSep= 0.5, vertexSepKey=None,
|
8454
|
+
rankSep= 0.5, rankSepKey=None,
|
8455
|
+
splines='true', splinesKey=None,
|
8456
|
+
showGraphLabel = False,
|
8457
|
+
graphLabel='', graphLabelKey=None,
|
8458
|
+
graphLabelLoc='t', graphLabelLocKey=None,
|
8459
|
+
|
8460
|
+
showVertexLabel = False,
|
8461
|
+
vertexLabelPrefix='' , vertexLabelKey=None,
|
8462
|
+
vertexWidth=0.5, vertexWidthKey=None,
|
8463
|
+
vertexHeight=0.5, vertexHeightKey=None,
|
8464
|
+
vertexFixedSize=False, vertexFixedSizeKey=None,
|
8465
|
+
vertexShape='circle', vertexShapeKey=None,
|
8466
|
+
vertexStyle='filled', vertexStyleKey=None,
|
8467
|
+
vertexFillColor='lightgray', vertexFillColorKey=None,
|
8468
|
+
vertexColor='black', vertexColorKey=None,
|
8469
|
+
vertexFontColor='black', vertexFontColorKey=None,
|
8470
|
+
|
8471
|
+
showEdgeLabel = False,
|
8472
|
+
edgeLabelPrefix='', edgeLabelKey=None,
|
8473
|
+
edgeColor='black', edgeColorKey=None,
|
8474
|
+
edgeWidth=1, edgeWidthKey=None,
|
8475
|
+
edgeStyle='solid', edgeStyleKey=None,
|
8476
|
+
edgeArrowhead='normal', edgeArrowheadKey=None,
|
8477
|
+
edgeFontColor='black', edgeFontColorKey=None,
|
8478
|
+
silent=False
|
8479
|
+
):
|
8480
|
+
"""
|
8481
|
+
Converts the input graph to a GraphViz graph. GraphViz should be installed separately, using your system's package manager.
|
8482
|
+
|
8483
|
+
Parameters
|
8484
|
+
----------
|
8485
|
+
graph : topologic_core.Graph
|
8486
|
+
The input graph.
|
8487
|
+
device : str, optional
|
8488
|
+
The output format device, such as 'svg_inline', 'pdf', or 'png'. The default is 'svg_inline'.
|
8489
|
+
deviceKey : str, optional
|
8490
|
+
Dictionary key to override the `device` value. Default is None.
|
8491
|
+
scale : float, optional
|
8492
|
+
Global scaling factor. Default is 1.
|
8493
|
+
scaleKey : str, optional
|
8494
|
+
Dictionary key to override the `scale` per-graph. Default is None.
|
8495
|
+
directed : bool, optional
|
8496
|
+
Whether to treat the graph as directed. Default is False.
|
8497
|
+
directedKey : str, optional
|
8498
|
+
Dictionary key to override the `directed` flag per-graph. Default is None.
|
8499
|
+
layout : str, optional
|
8500
|
+
Layout engine to use. Options include 'dot', 'circo', 'fdp', 'neato', 'osage', 'sfdp', etc. Default is 'dot'.
|
8501
|
+
layoutKey : str, optional
|
8502
|
+
Dictionary key to override the `layout` per-graph. Default is None.
|
8503
|
+
rankDir : str, optional
|
8504
|
+
Direction of graph ranking. Options: 'TB' (top-bottom), 'LR' (left-right), 'RL', 'BT'. Default is 'TB'.
|
8505
|
+
rankDirKey : str, optional
|
8506
|
+
Dictionary key to override `rankDir` per-graph. Default is None.
|
8507
|
+
bgColor : str, optional
|
8508
|
+
Background color. Default is 'white'.
|
8509
|
+
bgColorKey : str, optional
|
8510
|
+
Dictionary key to override `bgColor`. Default is None.
|
8511
|
+
fontName : str, optional
|
8512
|
+
Name of the font to use for all text. Default is 'Arial'.
|
8513
|
+
fontNameKey : str, optional
|
8514
|
+
Dictionary key to override `fontName`. Default is None.
|
8515
|
+
fontSize : int or float, optional
|
8516
|
+
Size of font in points. Default is 12.
|
8517
|
+
fontSizeKey : str, optional
|
8518
|
+
Dictionary key to override `fontSize`. Default is None.
|
8519
|
+
vertexSep : float, optional
|
8520
|
+
Minimum separation between vertices. Default is 0.5.
|
8521
|
+
vertexSepKey : str, optional
|
8522
|
+
Dictionary key to override `vertexSep`. Default is None.
|
8523
|
+
rankSep : float, optional
|
8524
|
+
Separation between ranks. Default is 0.5.
|
8525
|
+
rankSepKey : str, optional
|
8526
|
+
Dictionary key to override `rankSep`. Default is None.
|
8527
|
+
splines : str, optional
|
8528
|
+
Whether to use spline edges. Can be 'true', 'false', or 'polyline'. Default is 'True'.
|
8529
|
+
splinesKey : str, optional
|
8530
|
+
Dictionary key to override `splines`. Default is None.
|
8531
|
+
showGraphLabel : bool, optional
|
8532
|
+
Whether to show a label for the whole graph. Default is False.
|
8533
|
+
graphLabel : str, optional
|
8534
|
+
Text for the graph label. Default is an empty string.
|
8535
|
+
graphLabelKey : str, optional
|
8536
|
+
Dictionary key to override `graphLabel`. Default is None.
|
8537
|
+
graphLabelLoc : str, optional
|
8538
|
+
Position of the graph label: 't' (top), 'b' (bottom), 'c' (center). Default is 't'.
|
8539
|
+
graphLabelLocKey : str, optional
|
8540
|
+
Dictionary key to override `graphLabelLoc`. Default is None.
|
8541
|
+
showVertexLabel : bool, optional
|
8542
|
+
Whether to display vertex labels. Default is False.
|
8543
|
+
vertexLabelPrefix : str, optional
|
8544
|
+
Text prefix for vertex labels. Default is empty string.
|
8545
|
+
vertexLabelKey : str, optional
|
8546
|
+
Dictionary key used to retrieve label text from vertex dictionary. Default is None.
|
8547
|
+
vertexWidth : float, optional
|
8548
|
+
Width of each vertex. Default is 0.5.
|
8549
|
+
vertexWidthKey : str, optional
|
8550
|
+
Dictionary key to override `vertexWidth`. Default is None.
|
8551
|
+
vertexHeight : float, optional
|
8552
|
+
Height of each vertex. Default is 0.5.
|
8553
|
+
vertexHeightKey : str, optional
|
8554
|
+
Dictionary key to override `vertexHeight`. Default is None.
|
8555
|
+
vertexFixedSize : bool, optional
|
8556
|
+
Whether vertices should be fixed in size. Default is False.
|
8557
|
+
vertexFixedSizeKey : str, optional
|
8558
|
+
Dictionary key to override `vertexFixedSize`. Default is None.
|
8559
|
+
vertexShape : str, optional
|
8560
|
+
Shape of the vertex ('circle', 'ellipse', 'box', etc.). Default is 'circle'.
|
8561
|
+
vertexShapeKey : str, optional
|
8562
|
+
Dictionary key to override `vertexShape`. Default is None.
|
8563
|
+
vertexStyle : str, optional
|
8564
|
+
Style of vertex (e.g., 'filled', 'dashed'). Default is 'filled'.
|
8565
|
+
vertexStyleKey : str, optional
|
8566
|
+
Dictionary key to override `vertexStyle`. Default is None.
|
8567
|
+
vertexFillColor : str, optional
|
8568
|
+
Fill color for vertices. Default is 'lightgray'.
|
8569
|
+
vertexFillColorKey : str, optional
|
8570
|
+
Dictionary key to override `vertexFillColor`. Default is None.
|
8571
|
+
vertexColor : str, optional
|
8572
|
+
Border color for vertices. Default is 'black'.
|
8573
|
+
vertexColorKey : str, optional
|
8574
|
+
Dictionary key to override `vertexColor`. Default is None.
|
8575
|
+
vertexFontColor : str, optional
|
8576
|
+
Font color for vertex labels. Default is 'black'.
|
8577
|
+
vertexFontColorKey : str, optional
|
8578
|
+
Dictionary key to override `vertexFontColor`. Default is None.
|
8579
|
+
showEdgeLabel : bool, optional
|
8580
|
+
Whether to display edge labels. Default is False.
|
8581
|
+
edgeLabelPrefix : str, optional
|
8582
|
+
Text prefix for edge labels. Default is empty string.
|
8583
|
+
edgeLabelKey : str, optional
|
8584
|
+
Dictionary key used to retrieve label text from edge dictionary. Default is None.
|
8585
|
+
edgeColor : str, optional
|
8586
|
+
Color of edges. Default is 'black'.
|
8587
|
+
edgeColorKey : str, optional
|
8588
|
+
Dictionary key to override `edgeColor`. Default is None.
|
8589
|
+
edgeWidth : float, optional
|
8590
|
+
Width (thickness) of edges. Default is 1.
|
8591
|
+
edgeWidthKey : str, optional
|
8592
|
+
Dictionary key to override `edgeWidth`. Default is None.
|
8593
|
+
edgeStyle : str, optional
|
8594
|
+
Style of the edge line (e.g., 'solid', 'dashed'). Default is 'solid'.
|
8595
|
+
edgeStyleKey : str, optional
|
8596
|
+
Dictionary key to override `edgeStyle`. Default is None.
|
8597
|
+
edgeArrowhead : str, optional
|
8598
|
+
Arrowhead style for directed edges. Default is 'normal'.
|
8599
|
+
edgeArrowheadKey : str, optional
|
8600
|
+
Dictionary key to override `edgeArrowhead`. Default is None.
|
8601
|
+
edgeFontColor : str, optional
|
8602
|
+
Font color for edge labels. Default is 'black'.
|
8603
|
+
edgeFontColorKey : str, optional
|
8604
|
+
Dictionary key to override `edgeFontColor`. Default is None.
|
8605
|
+
overwrite : bool, optional
|
8606
|
+
If True, overwrites existing files at the given path. Default is False.
|
8607
|
+
silent : bool, optional
|
8608
|
+
If True, suppresses console output. Default is False.
|
8609
|
+
|
8610
|
+
Returns
|
8611
|
+
-------
|
8612
|
+
graphviz.graphs.Graph
|
8613
|
+
The created GraphViz graph.
|
8614
|
+
"""
|
8615
|
+
|
8616
|
+
from graphviz import Digraph
|
8617
|
+
from graphviz import Graph as Udgraph
|
8618
|
+
from topologicpy.Graph import Graph
|
8619
|
+
from topologicpy.Topology import Topology
|
8620
|
+
from topologicpy.Dictionary import Dictionary
|
8621
|
+
|
8622
|
+
if not Topology.IsInstance(graph, "Graph"):
|
8623
|
+
if not silent:
|
8624
|
+
print("Graph.GraphVizGraph - Error: the input graph parameter is not a valid graph. Returning None.")
|
8625
|
+
return None
|
8626
|
+
# Set Graph-level attributes
|
8627
|
+
def get_attr(dict, keyName, default):
|
8628
|
+
if keyName:
|
8629
|
+
return Dictionary.ValueAtKey(dict, keyName, default)
|
8630
|
+
return default
|
8631
|
+
|
8632
|
+
graph_dict = Topology.Dictionary(graph)
|
8633
|
+
|
8634
|
+
is_directed = get_attr(graph_dict, directedKey, directed)
|
8635
|
+
if is_directed:
|
8636
|
+
gv_graph = Digraph()
|
8637
|
+
else:
|
8638
|
+
gv_graph = Udgraph()
|
8639
|
+
|
8640
|
+
if showGraphLabel:
|
8641
|
+
label_value = get_attr(graph_dict, graphLabelKey, graphLabel)
|
8642
|
+
else:
|
8643
|
+
label_value = ''
|
8644
|
+
gv_graph.attr(
|
8645
|
+
layout = get_attr(graph_dict, layoutKey, layout),
|
8646
|
+
rankdir=get_attr(graph_dict, rankDirKey, rankDir),
|
8647
|
+
bgcolor=get_attr(graph_dict, bgColorKey, bgColor),
|
8648
|
+
fontname=get_attr(graph_dict, fontNameKey, fontName),
|
8649
|
+
fontsize=get_attr(graph_dict, fontSizeKey, str(fontSize)),
|
8650
|
+
vertexsep=get_attr(graph_dict, vertexSepKey, str(vertexSep)),
|
8651
|
+
ranksep=get_attr(graph_dict, rankSepKey, str(rankSep)),
|
8652
|
+
splines=get_attr(graph_dict, splinesKey, splines),
|
8653
|
+
label=label_value,
|
8654
|
+
labelloc=get_attr(graph_dict, graphLabelLocKey, graphLabelLoc),
|
8655
|
+
device = get_attr(graph_dict, deviceKey, device)
|
8656
|
+
)
|
8657
|
+
|
8658
|
+
# Get the Vertices and Edges from the Topologic Graph
|
8659
|
+
mesh_data = Graph.MeshData(graph)
|
8660
|
+
|
8661
|
+
# Set Vertex Attributes
|
8662
|
+
verts = mesh_data['vertices']
|
8663
|
+
vert_dicts = mesh_data['vertexDictionaries']
|
8664
|
+
for i, v in enumerate(verts):
|
8665
|
+
v_dict = vert_dicts[i]
|
8666
|
+
if showVertexLabel:
|
8667
|
+
label_value = get_attr(v_dict, vertexLabelKey, f"{vertexLabelPrefix}{i}")
|
8668
|
+
else:
|
8669
|
+
label_value = ''
|
8670
|
+
|
8671
|
+
fixed_size_value = get_attr(v_dict, vertexFixedSizeKey, vertexFixedSize)
|
8672
|
+
|
8673
|
+
if fixed_size_value:
|
8674
|
+
fixed_size_value = "True"
|
8675
|
+
else:
|
8676
|
+
fixed_size_value = "False"
|
8677
|
+
|
8678
|
+
if "nop" in get_attr(graph_dict, layoutKey, layout):
|
8679
|
+
pos_value = f"{v[0]*scale},{v[1]*scale}!"
|
8680
|
+
else:
|
8681
|
+
pos_value = ""
|
8682
|
+
gv_graph.node(
|
8683
|
+
str(i),
|
8684
|
+
pos = pos_value,
|
8685
|
+
label= label_value,
|
8686
|
+
shape=get_attr(v_dict, vertexShapeKey, vertexShape),
|
8687
|
+
width=str(get_attr(v_dict, vertexWidthKey, vertexWidth)),
|
8688
|
+
height=str(get_attr(v_dict, vertexHeightKey, vertexHeight)),
|
8689
|
+
fixedSize=fixed_size_value,
|
8690
|
+
style=get_attr(v_dict, vertexStyleKey, vertexStyle),
|
8691
|
+
fillcolor=get_attr(v_dict, vertexFillColorKey, vertexFillColor),
|
8692
|
+
color=get_attr(v_dict, vertexColorKey, vertexColor),
|
8693
|
+
fontcolor=get_attr(v_dict, vertexFontColorKey, vertexFontColor)
|
8694
|
+
)
|
8695
|
+
|
8696
|
+
# Set Edge attributes
|
8697
|
+
edges = mesh_data['edges']
|
8698
|
+
edge_dicts = mesh_data['edgeDictionaries']
|
8699
|
+
for i, e in enumerate(edges):
|
8700
|
+
sid = e[0]
|
8701
|
+
eid = e[1]
|
8702
|
+
|
8703
|
+
e_dict = edge_dicts[i]
|
8704
|
+
if showEdgeLabel:
|
8705
|
+
label_value = get_attr(e_dict, edgeLabelKey, f"{edgeLabelPrefix}{i}")
|
8706
|
+
else:
|
8707
|
+
label_value = ''
|
8708
|
+
|
8709
|
+
gv_graph.edge(
|
8710
|
+
str(sid),
|
8711
|
+
str(eid),
|
8712
|
+
label= label_value,
|
8713
|
+
color= get_attr(e_dict, edgeColorKey, edgeColor),
|
8714
|
+
penwidth=str(get_attr(e_dict, edgeWidthKey, edgeWidth)),
|
8715
|
+
style= get_attr(e_dict, edgeStyleKey, edgeStyle),
|
8716
|
+
arrowhead= get_attr(e_dict, edgeArrowheadKey, edgeArrowhead),
|
8717
|
+
fontcolor= get_attr(e_dict, edgeFontColorKey, edgeFontColor),
|
8718
|
+
)
|
8719
|
+
|
8720
|
+
return gv_graph
|
8721
|
+
|
8190
8722
|
@staticmethod
|
8191
8723
|
def Guid(graph):
|
8192
8724
|
"""
|
@@ -10544,36 +11076,36 @@ class Graph:
|
|
10544
11076
|
data = []
|
10545
11077
|
for graph in new_graphs:
|
10546
11078
|
data += Plotly.DataByGraph(graph,
|
10547
|
-
|
10548
|
-
|
10549
|
-
|
10550
|
-
|
10551
|
-
|
10552
|
-
|
10553
|
-
|
10554
|
-
|
10555
|
-
|
10556
|
-
|
10557
|
-
|
10558
|
-
|
10559
|
-
|
10560
|
-
|
10561
|
-
|
10562
|
-
|
10563
|
-
|
10564
|
-
|
10565
|
-
|
10566
|
-
|
10567
|
-
|
10568
|
-
|
10569
|
-
|
10570
|
-
|
10571
|
-
|
10572
|
-
|
10573
|
-
|
10574
|
-
|
10575
|
-
|
10576
|
-
|
11079
|
+
sagitta=sagitta,
|
11080
|
+
absolute=absolute,
|
11081
|
+
sides=sides,
|
11082
|
+
angle=angle,
|
11083
|
+
vertexColor=vertexColor,
|
11084
|
+
vertexColorKey=vertexColorKey,
|
11085
|
+
vertexSize=vertexSize,
|
11086
|
+
vertexSizeKey=vertexSizeKey,
|
11087
|
+
vertexLabelKey=vertexLabelKey,
|
11088
|
+
vertexGroupKey=vertexGroupKey,
|
11089
|
+
vertexGroups=vertexGroups,
|
11090
|
+
vertexMinGroup=vertexMinGroup,
|
11091
|
+
vertexMaxGroup=vertexMaxGroup,
|
11092
|
+
showVertices=showVertices,
|
11093
|
+
showVertexLabel=showVertexLabel,
|
11094
|
+
showVertexLegend=showVertexLegend,
|
11095
|
+
edgeColor=edgeColor,
|
11096
|
+
edgeColorKey=edgeColorKey,
|
11097
|
+
edgeWidth=edgeWidth,
|
11098
|
+
edgeWidthKey=edgeWidthKey,
|
11099
|
+
edgeLabelKey=edgeLabelKey,
|
11100
|
+
edgeGroupKey=edgeGroupKey,
|
11101
|
+
edgeGroups=edgeGroups,
|
11102
|
+
edgeMinGroup=edgeMinGroup,
|
11103
|
+
edgeMaxGroup=edgeMaxGroup,
|
11104
|
+
showEdges=showEdges,
|
11105
|
+
showEdgeLabel=showEdgeLabel,
|
11106
|
+
showEdgeLegend=showEdgeLegend,
|
11107
|
+
colorScale=colorScale,
|
11108
|
+
silent=silent)
|
10577
11109
|
fig = Plotly.FigureByData(data, width=width, height=height, xAxis=xAxis, yAxis=yAxis, zAxis=zAxis, axisSize=axisSize, backgroundColor=backgroundColor,
|
10578
11110
|
marginLeft=marginLeft, marginRight=marginRight, marginTop=marginTop, marginBottom=marginBottom, tolerance=tolerance)
|
10579
11111
|
Plotly.Show(fig, renderer=renderer, camera=camera, center=center, up=up, projection=projection)
|
topologicpy/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.8.
|
1
|
+
__version__ = '0.8.24'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: topologicpy
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.24
|
4
4
|
Summary: An AI-Powered Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
|
5
5
|
Author-email: Wassim Jabi <wassim.jabi@gmail.com>
|
6
6
|
License: AGPL v3 License
|
@@ -12,7 +12,7 @@ topologicpy/Dictionary.py,sha256=Lf24WHW8q_RCq0l8VpT3XJTn6UuStY66JI4Lb4W08jI,341
|
|
12
12
|
topologicpy/Edge.py,sha256=pu4tZbRbK8qx2oqRbwHAeKuwU2X8JFGPSJjJMTJw8Q0,71418
|
13
13
|
topologicpy/EnergyModel.py,sha256=Pyb28gDDwhzlQIH0xqAygqS0P3SJxWyyV7OWS_AAfRs,53856
|
14
14
|
topologicpy/Face.py,sha256=7K46gB_UIKjKEKyzyY0JqGarqjwjH0ggS-JQTpDtWC4,184847
|
15
|
-
topologicpy/Graph.py,sha256=
|
15
|
+
topologicpy/Graph.py,sha256=BCd6Zv_4J_-WRIP6nyX5FiqnJG1kDynGYelpN5y5S3g,552547
|
16
16
|
topologicpy/Grid.py,sha256=qRnFUvs079zMOZ6COWzBX6408niI7HyNz-BM0VRguXY,18245
|
17
17
|
topologicpy/Helper.py,sha256=JdvC30WMrla46mTj5TdwCV_bRv-6y8vK5Bkx0prluy4,29100
|
18
18
|
topologicpy/Honeybee.py,sha256=yctkwfdupKnp7bAOjP1Z4YaYpRrWoMEb4gz9Z5zaWwE,21751
|
@@ -29,9 +29,9 @@ topologicpy/Vector.py,sha256=mx7fgABdioikPWM9HzXKzmqfx3u_XBcU_jlLD4qK2x8,42407
|
|
29
29
|
topologicpy/Vertex.py,sha256=PIwfbA7_TxK_dSGlSeM5mson97TRr4dYrfZyOLgO150,80913
|
30
30
|
topologicpy/Wire.py,sha256=eRs4PM7h4yU5v6umPh0oBJR4cN8BwsqlVroaFdnvK4w,228499
|
31
31
|
topologicpy/__init__.py,sha256=RMftibjgAnHB1vdL-muo71RwMS4972JCxHuRHOlU428,928
|
32
|
-
topologicpy/version.py,sha256=
|
33
|
-
topologicpy-0.8.
|
34
|
-
topologicpy-0.8.
|
35
|
-
topologicpy-0.8.
|
36
|
-
topologicpy-0.8.
|
37
|
-
topologicpy-0.8.
|
32
|
+
topologicpy/version.py,sha256=c2VEZxOAKtWAyut3MMeHAIgcw2hpB1b9V0vR0y8Apb4,23
|
33
|
+
topologicpy-0.8.24.dist-info/licenses/LICENSE,sha256=FK0vJ73LuE8PYJAn7LutsReWR47-Ooovw2dnRe5yV6Q,681
|
34
|
+
topologicpy-0.8.24.dist-info/METADATA,sha256=RrGSLhJbNeivQQeKBNJUDMaYmKToe__QsEBWtR5sFEg,10535
|
35
|
+
topologicpy-0.8.24.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
36
|
+
topologicpy-0.8.24.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
|
37
|
+
topologicpy-0.8.24.dist-info/RECORD,,
|
File without changes
|
File without changes
|