topologicpy 0.8.25__py3-none-any.whl → 0.8.26__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 +49 -30
- topologicpy/version.py +1 -1
- {topologicpy-0.8.25.dist-info → topologicpy-0.8.26.dist-info}/METADATA +1 -1
- {topologicpy-0.8.25.dist-info → topologicpy-0.8.26.dist-info}/RECORD +7 -7
- {topologicpy-0.8.25.dist-info → topologicpy-0.8.26.dist-info}/WHEEL +0 -0
- {topologicpy-0.8.25.dist-info → topologicpy-0.8.26.dist-info}/licenses/LICENSE +0 -0
- {topologicpy-0.8.25.dist-info → topologicpy-0.8.26.dist-info}/top_level.txt +0 -0
topologicpy/Graph.py
CHANGED
@@ -4487,7 +4487,7 @@ class Graph:
|
|
4487
4487
|
weightClosenessCentrality: float = 0.0,
|
4488
4488
|
weightDegreeCentrality: float = 0.0,
|
4489
4489
|
weightDiameter: float = 0.0,
|
4490
|
-
|
4490
|
+
weightEigenVectorCentrality: float = 0.0,
|
4491
4491
|
weightGlobalClusteringCoefficient: float = 0.0,
|
4492
4492
|
weightPageRank: float = 0.0,
|
4493
4493
|
weightStructure: float = 0.0,
|
@@ -4521,8 +4521,8 @@ class Graph:
|
|
4521
4521
|
The desired weight for degree centrality similarity (graph-level and node-level). Default is 0.0.
|
4522
4522
|
weightDiameter : float , optional
|
4523
4523
|
The desired weight for diameter similarity (graph-level and node-level). Default is 0.0.
|
4524
|
-
|
4525
|
-
The desired weight for
|
4524
|
+
weightEigenVectorCentrality : float , optional
|
4525
|
+
The desired weight for eigenvector centrality similarity (graph-level and node-level). Default is 0.0.
|
4526
4526
|
weightGeometry : float , optional
|
4527
4527
|
The desired weight for geometric similarity (vertex positions). Default is 0.0.
|
4528
4528
|
weightGlobalClusteringCoefficient : float , optional
|
@@ -4559,7 +4559,7 @@ class Graph:
|
|
4559
4559
|
"betwenness_centrality"
|
4560
4560
|
"closeness_centrality"
|
4561
4561
|
"degree_centrality"
|
4562
|
-
"
|
4562
|
+
"eigenvector_centrality"
|
4563
4563
|
"geometry"
|
4564
4564
|
"global_clustering_coefficient"
|
4565
4565
|
"jaccard"
|
@@ -4722,9 +4722,9 @@ class Graph:
|
|
4722
4722
|
diff = abs(v1 - v2) / max(abs(v1), abs(v2), 1e-6)
|
4723
4723
|
return round((1 - diff), mantissa)
|
4724
4724
|
|
4725
|
-
def
|
4726
|
-
v1 = safe_mean(Graph.
|
4727
|
-
v2 = safe_mean(Graph.
|
4725
|
+
def eigenvector_centrality_similarity(graphA, graphB, mantissa=6):
|
4726
|
+
v1 = safe_mean(Graph.EigenVectorCentrality(graphA))
|
4727
|
+
v2 = safe_mean(Graph.EigenVectorCentrality(graphB))
|
4728
4728
|
if v1 == 0 and v2 == 0:
|
4729
4729
|
return 1
|
4730
4730
|
diff = abs(v1 - v2) / max(abs(v1), abs(v2), 1e-6)
|
@@ -4807,7 +4807,7 @@ class Graph:
|
|
4807
4807
|
weightClosenessCentrality,
|
4808
4808
|
weightDegreeCentrality,
|
4809
4809
|
weightDiameter,
|
4810
|
-
|
4810
|
+
weightEigenVectorCentrality,
|
4811
4811
|
weightGlobalClusteringCoefficient,
|
4812
4812
|
weightPageRank,
|
4813
4813
|
weightStructure,
|
@@ -4819,7 +4819,7 @@ class Graph:
|
|
4819
4819
|
closeness_centrality_score = closeness_centrality_similarity(graphA, graphB, mantissa=mantissa) if weightClosenessCentrality else 0
|
4820
4820
|
degree_centrality_score = degree_centrality_similarity(graphA, graphB, mantissa=mantissa) if weightDegreeCentrality else 0
|
4821
4821
|
diameter_score = diameter_similarity(graphA, graphB, mantissa=mantissa) if weightDiameter else 0
|
4822
|
-
|
4822
|
+
eigenvector_centrality_score = eigenvector_centrality_similarity(graphA, graphB, mantissa=mantissa) if weightEigenVectorCentrality else 0
|
4823
4823
|
global_clustering_coefficient_score = global_clustering_coefficient_similarity(graphA, graphB, mantissa=mantissa) if weightGlobalClusteringCoefficient else 0
|
4824
4824
|
geometry_score = geometry_similarity(graphA, graphB, mantissa=mantissa) if weightGeometry else 0
|
4825
4825
|
jaccard_score = weighted_jaccard_similarity(graphA, graphB, vertexIDKey=vertexIDKey, edgeWeightKey=edgeWeightKey, mantissa=mantissa) if weightJaccard else 0
|
@@ -4834,7 +4834,7 @@ class Graph:
|
|
4834
4834
|
closeness_centrality_score * weightClosenessCentrality +
|
4835
4835
|
degree_centrality_score * weightDegreeCentrality +
|
4836
4836
|
diameter_score * weightDiameter +
|
4837
|
-
|
4837
|
+
eigenvector_centrality_score * weightEigenVectorCentrality +
|
4838
4838
|
geometry_score * weightGeometry +
|
4839
4839
|
global_clustering_coefficient_score * weightGlobalClusteringCoefficient +
|
4840
4840
|
jaccard_score * weightJaccard +
|
@@ -4854,7 +4854,7 @@ class Graph:
|
|
4854
4854
|
"betwenness_centrality": round(betweenness_centrality_score, mantissa),
|
4855
4855
|
"closeness_centrality": round(closeness_centrality_score, mantissa),
|
4856
4856
|
"degree_centrality": round(degree_centrality_score, mantissa),
|
4857
|
-
"
|
4857
|
+
"eigenvector_centrality": round(eigenvector_centrality_score, mantissa),
|
4858
4858
|
"geometry": round(geometry_score, mantissa),
|
4859
4859
|
"global_clustering_coefficient": round(global_clustering_coefficient_score, mantissa),
|
4860
4860
|
"jaccard": round(jaccard_score, mantissa),
|
@@ -5239,9 +5239,9 @@ class Graph:
|
|
5239
5239
|
if "len" in weightKey.lower() or "dis" in weightKey.lower():
|
5240
5240
|
weightKey = "length"
|
5241
5241
|
nx_graph = Graph.NetworkXGraph(graph)
|
5242
|
-
|
5243
|
-
|
5244
|
-
values = [round(v, mantissa) for v in list(
|
5242
|
+
vertices = Graph.Vertices(graph)
|
5243
|
+
vertices_dict = nx.closeness_centrality(nx_graph, distance=weightKey, wf_improved=nxCompatible)
|
5244
|
+
values = [round(v, mantissa) for v in list(vertices_dict.values())]
|
5245
5245
|
if normalize == True:
|
5246
5246
|
if mantissa > 0: # We cannot round numbers from 0 to 1 with a mantissa = 0.
|
5247
5247
|
values = [round(v, mantissa) for v in Helper.Normalize(values)]
|
@@ -5254,10 +5254,10 @@ class Graph:
|
|
5254
5254
|
max_value = max(values)
|
5255
5255
|
|
5256
5256
|
for i, value in enumerate(values):
|
5257
|
-
d = Topology.Dictionary(
|
5257
|
+
d = Topology.Dictionary(vertices[i])
|
5258
5258
|
color = Color.AnyToHex(Color.ByValueInRange(value, minValue=min_value, maxValue=max_value, colorScale=colorScale))
|
5259
5259
|
d = Dictionary.SetValuesAtKeys(d, [key, colorKey], [value, color])
|
5260
|
-
|
5260
|
+
vertices[i] = Topology.SetDictionary(vertices[i], d)
|
5261
5261
|
|
5262
5262
|
return values
|
5263
5263
|
|
@@ -6051,7 +6051,7 @@ class Graph:
|
|
6051
6051
|
return list(dict.fromkeys(edges)) # remove duplicates
|
6052
6052
|
|
6053
6053
|
@staticmethod
|
6054
|
-
def
|
6054
|
+
def EigenVectorCentrality(graph, normalize: bool = False, key: str = "eigen_vector_centrality", colorKey: str = "evc_color", colorScale: str = "viridis", mantissa: int = 6, tolerance: float = 0.0001, silent: bool = False):
|
6055
6055
|
"""
|
6056
6056
|
Returns the eigenvector centrality of the input graph. The order of the returned list is the same as the order of vertices.
|
6057
6057
|
|
@@ -6064,9 +6064,9 @@ class Graph:
|
|
6064
6064
|
normalize : bool, optional
|
6065
6065
|
If set to True, the centrality values are normalized to be in the range 0 to 1. The default is False.
|
6066
6066
|
key : str, optional
|
6067
|
-
The desired dictionary key under which to store the eigenvector centrality score. The default is "
|
6067
|
+
The desired dictionary key under which to store the eigenvector centrality score. The default is "eigen_vector_centrality".
|
6068
6068
|
colorKey : str, optional
|
6069
|
-
The desired dictionary key under which to store the eigenvector centrality color. The default is "
|
6069
|
+
The desired dictionary key under which to store the eigenvector centrality color. The default is "evc_color".
|
6070
6070
|
colorScale : str, optional
|
6071
6071
|
The desired type of Plotly color scale to use (e.g., "viridis", "plasma"). Default is "viridis".
|
6072
6072
|
For a full list of names, see https://plotly.com/python/builtin-colorscales/.
|
@@ -6092,7 +6092,7 @@ class Graph:
|
|
6092
6092
|
|
6093
6093
|
if not Topology.IsInstance(graph, "graph"):
|
6094
6094
|
if not silent:
|
6095
|
-
print("Graph.
|
6095
|
+
print("Graph.EigenVectorCentrality - Error: The input graph is not a valie Topologic Graph. Returning None.")
|
6096
6096
|
return None
|
6097
6097
|
adjacency_matrix = Graph.AdjacencyMatrix(graph)
|
6098
6098
|
vertices = Graph.Vertices(graph)
|
@@ -10474,9 +10474,9 @@ class Graph:
|
|
10474
10474
|
return outgoing_vertices
|
10475
10475
|
|
10476
10476
|
@staticmethod
|
10477
|
-
def PageRank(graph, alpha: float = 0.85, maxIterations: int = 100, normalize: bool = True, directed: bool = False, key: str = "page_rank", mantissa: int = 6, tolerance: float = 0.0001):
|
10477
|
+
def PageRank(graph, alpha: float = 0.85, maxIterations: int = 100, normalize: bool = True, directed: bool = False, key: str = "page_rank", colorKey="pr_color", colorScale="viridis", mantissa: int = 6, tolerance: float = 0.0001):
|
10478
10478
|
"""
|
10479
|
-
Calculates PageRank scores for
|
10479
|
+
Calculates PageRank scores for vertices in a directed graph. see https://en.wikipedia.org/wiki/PageRank.
|
10480
10480
|
|
10481
10481
|
Parameters
|
10482
10482
|
----------
|
@@ -10492,6 +10492,11 @@ class Graph:
|
|
10492
10492
|
If set to True, the graph is considered as a directed graph. Otherwise, it will be considered as an undirected graph. The default is False.
|
10493
10493
|
key : str , optional
|
10494
10494
|
The dictionary key under which to store the page_rank score. The default is "page_rank"
|
10495
|
+
colorKey : str , optional
|
10496
|
+
The desired dictionary key under which to store the pagerank color. The default is "pr_color".
|
10497
|
+
colorScale : str , optional
|
10498
|
+
The desired type of plotly color scales to use (e.g. "viridis", "plasma"). The default is "viridis". For a full list of names, see https://plotly.com/python/builtin-colorscales/.
|
10499
|
+
In addition to these, three color-blind friendly scales are included. These are "protanopia", "deuteranopia", and "tritanopia" for red, green, and blue colorblindness respectively.
|
10495
10500
|
mantissa : int , optional
|
10496
10501
|
The desired length of the mantissa.
|
10497
10502
|
tolerance : float , optional
|
@@ -10506,6 +10511,7 @@ class Graph:
|
|
10506
10511
|
from topologicpy.Helper import Helper
|
10507
10512
|
from topologicpy.Dictionary import Dictionary
|
10508
10513
|
from topologicpy.Topology import Topology
|
10514
|
+
from topologicpy.Color import Color
|
10509
10515
|
|
10510
10516
|
vertices = Graph.Vertices(graph)
|
10511
10517
|
num_vertices = len(vertices)
|
@@ -10513,7 +10519,7 @@ class Graph:
|
|
10513
10519
|
print("Graph.PageRank - Error: The input graph parameter has no vertices. Returning None")
|
10514
10520
|
return None
|
10515
10521
|
initial_score = 1.0 / num_vertices
|
10516
|
-
|
10522
|
+
values = [initial_score for vertex in vertices]
|
10517
10523
|
for _ in range(maxIterations):
|
10518
10524
|
new_scores = [0 for vertex in vertices]
|
10519
10525
|
for i, vertex in enumerate(vertices):
|
@@ -10522,23 +10528,36 @@ class Graph:
|
|
10522
10528
|
if len(Graph.IncomingVertices(graph, incoming_vertex, directed=directed)) > 0:
|
10523
10529
|
vi = Vertex.Index(incoming_vertex, vertices, tolerance=tolerance)
|
10524
10530
|
if not vi == None:
|
10525
|
-
incoming_score +=
|
10531
|
+
incoming_score += values[vi] / len(Graph.IncomingVertices(graph, incoming_vertex, directed=directed))
|
10526
10532
|
new_scores[i] = alpha * incoming_score + (1 - alpha) / num_vertices
|
10527
10533
|
|
10528
10534
|
# Check for convergence
|
10529
|
-
if all(abs(new_scores[i] -
|
10535
|
+
if all(abs(new_scores[i] - values[i]) <= tolerance for i in range(len(vertices))):
|
10530
10536
|
break
|
10531
10537
|
|
10532
|
-
|
10538
|
+
values = new_scores
|
10533
10539
|
if normalize == True:
|
10534
|
-
|
10540
|
+
if mantissa > 0: # We cannot round numbers from 0 to 1 with a mantissa = 0.
|
10541
|
+
values = [round(v, mantissa) for v in Helper.Normalize(values)]
|
10542
|
+
else:
|
10543
|
+
values = Helper.Normalize(values)
|
10544
|
+
min_value = 0
|
10545
|
+
max_value = 1
|
10535
10546
|
else:
|
10536
|
-
|
10547
|
+
min_value = min(values)
|
10548
|
+
max_value = max(values)
|
10549
|
+
|
10550
|
+
for i, value in enumerate(values):
|
10551
|
+
d = Topology.Dictionary(vertices[i])
|
10552
|
+
color = Color.AnyToHex(Color.ByValueInRange(value, minValue=min_value, maxValue=max_value, colorScale=colorScale))
|
10553
|
+
d = Dictionary.SetValuesAtKeys(d, [key, colorKey], [value, color])
|
10554
|
+
vertices[i] = Topology.SetDictionary(vertices[i], d)
|
10555
|
+
|
10537
10556
|
for i, v in enumerate(vertices):
|
10538
10557
|
d = Topology.Dictionary(v)
|
10539
|
-
d = Dictionary.SetValueAtKey(d, key,
|
10558
|
+
d = Dictionary.SetValueAtKey(d, key, values[i])
|
10540
10559
|
v = Topology.SetDictionary(v, d)
|
10541
|
-
return
|
10560
|
+
return values
|
10542
10561
|
|
10543
10562
|
@staticmethod
|
10544
10563
|
def Partition(graph, method: str = "Betweenness", n: int = 2, m: int = 10, key: str ="partition",
|
topologicpy/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '0.8.
|
1
|
+
__version__ = '0.8.26'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: topologicpy
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.26
|
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=9gK-dEMtjo7KOXbCACpgwOYWhgTAHy42g6WiQ-rw20M,563389
|
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=rN0alF_hLv16P_Fcr4gxu7bHFSkbtvltSnm1X_HNZ5w,23
|
33
|
+
topologicpy-0.8.26.dist-info/licenses/LICENSE,sha256=FK0vJ73LuE8PYJAn7LutsReWR47-Ooovw2dnRe5yV6Q,681
|
34
|
+
topologicpy-0.8.26.dist-info/METADATA,sha256=D7oAeLuTLnKLuMBL8WSrlBMwSSjsK5QpsodjjHXkc7E,10535
|
35
|
+
topologicpy-0.8.26.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
36
|
+
topologicpy-0.8.26.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
|
37
|
+
topologicpy-0.8.26.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|