topologicpy 0.4.81__py3-none-any.whl → 0.4.83__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 CHANGED
@@ -4315,6 +4315,87 @@ class Graph:
4315
4315
  return None
4316
4316
  return graph.GetGUID()
4317
4317
 
4318
+ @staticmethod
4319
+ def IncomingEdges(graph: topologic.Graph, vertex: topologic.Vertex, directed: bool=False, tolerance: float=0.0001) -> list:
4320
+ """
4321
+ Returns the incoming edges connected to a vertex. An edge is considered incoming if its end vertex is
4322
+ coincident with the input vertex.
4323
+
4324
+ Parameters
4325
+ ----------
4326
+ graph : topologic.Graph
4327
+ The input graph.
4328
+ vertex : topologic.Vertex
4329
+ The input vertex.
4330
+ directed : bool , optional
4331
+ If set to True, the graph is considered to be directed. Otherwise, it will be considered as an unidrected graph. The default is False.
4332
+ tolerance : float , optional
4333
+ The desired tolerance. The default is 0.0001.
4334
+
4335
+ Returns
4336
+ -------
4337
+ list
4338
+ The list of incoming edges
4339
+
4340
+ """
4341
+ from topologicpy.Edge import Edge
4342
+ if not isinstance(graph, topologic.Graph):
4343
+ print("Graph.IncomingEdges - Error: The input graph parameter is not a valid graph. Returning None.")
4344
+ return None
4345
+ if not isinstance(vertex, topologic.Vertex):
4346
+ print("Graph.IncomingEdges - Error: The input vertex parameter is not a valid vertex. Returning None.")
4347
+ return None
4348
+
4349
+ edges = Graph.Edges(graph, [vertex])
4350
+ if directed == False:
4351
+ return edges
4352
+ incoming_edges = []
4353
+ for edge in edges:
4354
+ ev = Edge.EndVertex(edge)
4355
+ if Vertex.Distance(vertex, ev) < tolerance:
4356
+ incoming_edges.append(edge)
4357
+ return incoming_edges
4358
+
4359
+ @staticmethod
4360
+ def IncomingVertices(graph: topologic.Graph, vertex: topologic.Vertex, directed: bool=False, tolerance: float=0.0001) -> list:
4361
+ """
4362
+ Returns the incoming vertices connected to a vertex. A vertex is considered incoming if it is an adjacent vertex to the input vertex
4363
+ and the the edge connecting it to the input vertex is an incoming edge.
4364
+
4365
+ Parameters
4366
+ ----------
4367
+ graph : topologic.Graph
4368
+ The input graph.
4369
+ vertex : topologic.Vertex
4370
+ The input vertex.
4371
+ directed : bool , optional
4372
+ If set to True, the graph is considered to be directed. Otherwise, it will be considered as an unidrected graph. The default is False.
4373
+ tolerance : float , optional
4374
+ The desired tolerance. The default is 0.0001.
4375
+
4376
+ Returns
4377
+ -------
4378
+ list
4379
+ The list of incoming vertices
4380
+
4381
+ """
4382
+ from topologicpy.Edge import Edge
4383
+ if not isinstance(graph, topologic.Graph):
4384
+ print("Graph.IncomingVertices - Error: The input graph parameter is not a valid graph. Returning None.")
4385
+ return None
4386
+ if not isinstance(vertex, topologic.Vertex):
4387
+ print("Graph.IncomingVertices - Error: The input vertex parameter is not a valid vertex. Returning None.")
4388
+ return None
4389
+
4390
+ if directed == False:
4391
+ return Graph.AdjacentVertices(graph, vertex)
4392
+ incoming_edges = Graph.IncomingEdges(graph, vertex, directed=directed, tolerance=tolerance)
4393
+ incoming_vertices = []
4394
+ for edge in incoming_edges:
4395
+ sv = Edge.StartVertex(edge)
4396
+ incoming_vertices.append(Graph.NearestVertex(graph, sv))
4397
+ return incoming_vertices
4398
+
4318
4399
  @staticmethod
4319
4400
  def IsBipartite(graph, tolerance=0.0001):
4320
4401
  """
@@ -5142,7 +5223,144 @@ class Graph:
5142
5223
  print("Graph.Order - Error: The input graph is not a valid graph. Returning None.")
5143
5224
  return None
5144
5225
  return len(Graph.Vertices(graph))
5226
+
5227
+ @staticmethod
5228
+ def OutgoingEdges(graph: topologic.Graph, vertex: topologic.Vertex, directed: bool=False, tolerance: float=0.0001) -> list:
5229
+ """
5230
+ Returns the outgoing edges connected to a vertex. An edge is considered outgoing if its start vertex is
5231
+ coincident with the input vertex.
5232
+
5233
+ Parameters
5234
+ ----------
5235
+ graph : topologic.Graph
5236
+ The input graph.
5237
+ vertex : topologic.Vertex
5238
+ The input vertex.
5239
+ directed : bool , optional
5240
+ If set to True, the graph is considered to be directed. Otherwise, it will be considered as an unidrected graph. The default is False.
5241
+ tolerance : float , optional
5242
+ The desired tolerance. The default is 0.0001.
5243
+
5244
+ Returns
5245
+ -------
5246
+ list
5247
+ The list of outgoing edges
5145
5248
 
5249
+ """
5250
+ from topologicpy.Edge import Edge
5251
+ if not isinstance(graph, topologic.Graph):
5252
+ print("Graph.IncomingEdges - Error: The input graph parameter is not a valid graph. Returning None.")
5253
+ return None
5254
+ if not isinstance(vertex, topologic.Vertex):
5255
+ print("Graph.IncomingEdges - Error: The input vertex parameter is not a valid vertex. Returning None.")
5256
+ return None
5257
+
5258
+ edges = Graph.Edges(graph, [vertex])
5259
+ if directed == False:
5260
+ return edges
5261
+ outgoing_edges = []
5262
+ for edge in edges:
5263
+ sv = Edge.StartVertex(edge)
5264
+ if Vertex.Distance(vertex, sv) < tolerance:
5265
+ outgoing_edges.append(edge)
5266
+ return outgoing_edges
5267
+
5268
+ @staticmethod
5269
+ def OutgoingVertices(graph: topologic.Graph, vertex: topologic.Vertex, directed: bool=False, tolerance: float=0.0001) -> list:
5270
+ """
5271
+ Returns the list of outgoing vertices connected to a vertex. A vertex is considered outgoing if it is an adjacent vertex to the input vertex
5272
+ and the the edge connecting it to the input vertex is an outgoing edge.
5273
+
5274
+ Parameters
5275
+ ----------
5276
+ graph : topologic.Graph
5277
+ The input graph.
5278
+ vertex : topologic.Vertex
5279
+ The input vertex.
5280
+ directed : bool , optional
5281
+ If set to True, the graph is considered to be directed. Otherwise, it will be considered as an unidrected graph. The default is False.
5282
+ tolerance : float , optional
5283
+ The desired tolerance. The default is 0.0001.
5284
+
5285
+ Returns
5286
+ -------
5287
+ list
5288
+ The list of incoming vertices
5289
+
5290
+ """
5291
+ from topologicpy.Edge import Edge
5292
+ if not isinstance(graph, topologic.Graph):
5293
+ print("Graph.OutgoingVertices - Error: The input graph parameter is not a valid graph. Returning None.")
5294
+ return None
5295
+ if not isinstance(vertex, topologic.Vertex):
5296
+ print("Graph.OutgoingVertices - Error: The input vertex parameter is not a valid vertex. Returning None.")
5297
+ return None
5298
+
5299
+ if directed == False:
5300
+ return Graph.AdjacentVertices(graph, vertex)
5301
+ outgoing_edges = Graph.OutgoingEdges(graph, vertex, directed=directed, tolerance=tolerance)
5302
+ outgoing_vertices = []
5303
+ for edge in outgoing_edges:
5304
+ ev = Edge.EndVertex(edge)
5305
+ outgoing_vertices.append(Graph.NearestVertex(graph, ev))
5306
+ return outgoing_vertices
5307
+
5308
+ @staticmethod
5309
+ def PageRank(graph, alpha=0.85, maxIterations=100, normalize=True, directed=False, mantissa=6, tolerance=0.0001):
5310
+ """
5311
+ Calculates PageRank scores for nodes in a directed graph. see https://en.wikipedia.org/wiki/PageRank.
5312
+
5313
+ Parameters
5314
+ ----------
5315
+ graph : topologic.Graph
5316
+ The input graph.
5317
+ alpha : float , optional
5318
+ The damping (dampening) factor. The default is 0.85. See https://en.wikipedia.org/wiki/PageRank.
5319
+ maxIterations : int , optional
5320
+ The maximum number of iterations to calculate the page rank. The default is 100.
5321
+ normalize : bool , optional
5322
+ If set to True, the results will be normalized from 0 to 1. Otherwise, they won't be. The default is True.
5323
+ directed : bool , optional
5324
+ 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.
5325
+ mantissa : int , optional
5326
+ The desired length of the mantissa.
5327
+ tolerance : float , optional
5328
+ The desired tolerance. The default is 0.0001.
5329
+
5330
+ Returns
5331
+ -------
5332
+ list
5333
+ The list of page ranks for the vertices in the graph.
5334
+ """
5335
+ from topologicpy.Helper import Helper
5336
+
5337
+ vertices = Graph.Vertices(graph)
5338
+ num_vertices = len(vertices)
5339
+ if num_vertices < 1:
5340
+ print("Graph.PageRank - Error: The input graph parameter has no vertices. Returning None")
5341
+ return None
5342
+ initial_score = 1.0 / num_vertices
5343
+ scores = [initial_score for vertex in vertices]
5344
+ for _ in range(maxIterations):
5345
+ new_scores = [0 for vertex in vertices]
5346
+ for i, vertex in enumerate(vertices):
5347
+ incoming_score = 0
5348
+ for incoming_vertex in Graph.IncomingVertices(graph, vertex, directed=directed):
5349
+ if len(Graph.IncomingVertices(graph, incoming_vertex, directed=directed)) > 0:
5350
+ incoming_score += scores[Vertex.Index(incoming_vertex, vertices)] / len(Graph.IncomingVertices(graph, incoming_vertex, directed=directed))
5351
+ new_scores[i] = alpha * incoming_score + (1 - alpha) / num_vertices
5352
+
5353
+ # Check for convergence
5354
+ if all(abs(new_scores[i] - scores[i]) < tolerance for i in range(len(vertices))):
5355
+ break
5356
+
5357
+ scores = new_scores
5358
+ if normalize == True:
5359
+ scores = Helper.Normalize(scores, mantissa=mantissa)
5360
+ else:
5361
+ scores = [round(x, mantissa) for x in scores]
5362
+ return scores
5363
+
5146
5364
  @staticmethod
5147
5365
  def Path(graph, vertexA, vertexB):
5148
5366
  """
@@ -5835,7 +6053,7 @@ class Graph:
5835
6053
  return Graph.ByVerticesEdges(dictionary['vertices'], dictionary['edges'])
5836
6054
 
5837
6055
  @staticmethod
5838
- def VertexDegree(graph, vertex):
6056
+ def VertexDegree(graph : topologic.Graph, vertex: topologic.Vertex, edgeKey: str=None, tolerance: float=0.0001):
5839
6057
  """
5840
6058
  Returns the degree of the input vertex. See https://en.wikipedia.org/wiki/Degree_(graph_theory).
5841
6059
 
@@ -5843,8 +6061,13 @@ class Graph:
5843
6061
  ----------
5844
6062
  graph : topologic.Graph
5845
6063
  The input graph.
5846
- vertices : topologic.Vertex
6064
+ vertex : topologic.Vertex
5847
6065
  The input vertex.
6066
+ edgeKey : str , optional
6067
+ If specified, the value in the connected edges' dictionary specified by the edgeKey string will be aggregated to calculate
6068
+ the vertex degree. If a numeric value cannot be retrieved from an edge, a value of 1 is used instead. This is used in weighted graphs.
6069
+ tolerance : float , optional
6070
+ The desired tolerance. The default is 0.0001.
5848
6071
 
5849
6072
  Returns
5850
6073
  -------
@@ -5852,13 +6075,28 @@ class Graph:
5852
6075
  The degree of the input vertex.
5853
6076
 
5854
6077
  """
6078
+ from topologicpy.Topology import Topology
6079
+ from topologicpy.Dictionary import Dictionary
6080
+ import numbers
6081
+
5855
6082
  if not isinstance(graph, topologic.Graph):
5856
6083
  print("Graph.VertexDegree - Error: The input graph is not a valid graph. Returning None.")
5857
6084
  return None
5858
6085
  if not isinstance(vertex, topologic.Vertex):
5859
6086
  print("Graph.VertexDegree - Error: The input vertex is not a valid vertex. Returning None.")
5860
6087
  return None
5861
- return graph.VertexDegree(vertex)
6088
+ if not isinstance(edgeKey, str):
6089
+ edgeKey = ""
6090
+ edges = Graph.Edges(graph, [vertex], tolerance=tolerance)
6091
+ degree = 0
6092
+ for edge in edges:
6093
+ d = Topology.Dictionary(edge)
6094
+ value = Dictionary.ValueAtKey(d, edgeKey)
6095
+ if isinstance(value, numbers.Number):
6096
+ degree += value
6097
+ else:
6098
+ degree += 1
6099
+ return degree
5862
6100
 
5863
6101
  @staticmethod
5864
6102
  def Vertices(graph):
topologicpy/__init__.py CHANGED
@@ -18,7 +18,7 @@ import sys
18
18
  import os, re
19
19
  from sys import platform
20
20
 
21
- __version__ = '0.4.81'
21
+ __version__ = '0.4.83'
22
22
  __version_info__ = tuple([ int(num) for num in __version__.split('.')])
23
23
 
24
24
  if platform == 'win32':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: topologicpy
3
- Version: 0.4.81
3
+ Version: 0.4.83
4
4
  Summary: An Advanced Spatial Modelling and Analysis Software Library for Architecture, Engineering, and Construction.
5
5
  Author-email: Wassim Jabi <wassim.jabi@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/wassimj/TopologicPy
@@ -9,7 +9,7 @@ topologicpy/Dictionary.py,sha256=vGhiXPu7e7GsgQyTsX6rZBncnnrDlcYfM9xRb9h-l3U,247
9
9
  topologicpy/Edge.py,sha256=lMO4TSzN3AJNgS5Vfvl0DBY-aMn8S82xT4TXs7LdUnc,45644
10
10
  topologicpy/EnergyModel.py,sha256=WsK40w0eO6WswV6JxYztvX6zBFwTNFvDHOScXxACf08,51760
11
11
  topologicpy/Face.py,sha256=y3yWBEI4TlXJu-eOFHOgeoiZl_hGxev3jVE6T4cRPPs,93600
12
- topologicpy/Graph.py,sha256=fR-INihwPVS9EIJElBFUIAu5z_vYKBeGLb1xrb8_Vk4,287314
12
+ topologicpy/Graph.py,sha256=ne0TNs-NlboFqn_cX5LDbzSFa_7JqIsnJBVtMtw5bEQ,297966
13
13
  topologicpy/Grid.py,sha256=q6uAs8MGbdteYNbjqRjqlhFMquYAvSngwzxsFl9-338,17371
14
14
  topologicpy/Helper.py,sha256=nG9v3_v4XhPH0HM1lNkLqJ_z1LIjxsugCu_HxG0voYA,13680
15
15
  topologicpy/Honeybee.py,sha256=ygiGMS7u-YQJWpK2CmkBuJu1DBABVUmpMdg9HewOhN4,20349
@@ -23,7 +23,7 @@ topologicpy/Topology.py,sha256=7JRQhi7xaExb6BHZxrr13ddSgiflaT_tooxY8_tjgDA,28775
23
23
  topologicpy/Vector.py,sha256=57ZoYLd3chEQhjN8Sf1Wv_UR3klltLoaT8TQN0kP-f8,22166
24
24
  topologicpy/Vertex.py,sha256=A7hCI-WpHaemow4eDiaqVhZ0ekgifXcWFpa-82txwYM,55187
25
25
  topologicpy/Wire.py,sha256=gMqOqNOmph2Elup6j8bNrorBZfCScVChjTvq03rB6NA,133812
26
- topologicpy/__init__.py,sha256=5gBXJEnZSkDphJspvkkNvUYZe5NrO55EHCtilpPIoGs,1445
26
+ topologicpy/__init__.py,sha256=AVnRhV2NJfG_1EgkMS7jGdBkJJbAmOor1SlmNNEzWJU,1445
27
27
  topologicpy/bin/linux/topologic/__init__.py,sha256=XlFReDf3FWlYdM9uXtanYPIafgPb6GVTQczS_xJAXD0,60
28
28
  topologicpy/bin/linux/topologic/libTKBO-6bdf205d.so.7.7.0,sha256=ANok9DQKcnWcLd9T_LAt-i-X4nsYYy16q9kQlcTre1E,2996488
29
29
  topologicpy/bin/linux/topologic/libTKBRep-2960a069.so.7.7.0,sha256=OJ3XesL79du8LeBHrsleGPXub6OpJdOilxha0mwjqQo,1378768
@@ -84,8 +84,8 @@ topologicpy/bin/windows/topologic/topologic.cp310-win_amd64.pyd,sha256=F0sPLuMpD
84
84
  topologicpy/bin/windows/topologic/topologic.cp311-win_amd64.pyd,sha256=aBAJQj3OmJ58MOAF1ZIFybL_5fFK7FNR9hrIps6b6pc,1551872
85
85
  topologicpy/bin/windows/topologic/topologic.cp38-win_amd64.pyd,sha256=aLgNf54nbJmGc7Tdmkuy-V0m6B9zLxabIbpRwAy7cBA,1551360
86
86
  topologicpy/bin/windows/topologic/topologic.cp39-win_amd64.pyd,sha256=_8cp205hiRxkFHtzQQOweA4DhCPk8caH4kTVLWGQeVw,1411584
87
- topologicpy-0.4.81.dist-info/LICENSE,sha256=RUmXeeqj63bBySLJjEfhwb9OE7M8h9K6HuOBF3ASVyI,35697
88
- topologicpy-0.4.81.dist-info/METADATA,sha256=biyhimTuB8q6I7xWQP9TxTO8Jr45dYVhEx8tPN-2wVs,7252
89
- topologicpy-0.4.81.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
90
- topologicpy-0.4.81.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
91
- topologicpy-0.4.81.dist-info/RECORD,,
87
+ topologicpy-0.4.83.dist-info/LICENSE,sha256=RUmXeeqj63bBySLJjEfhwb9OE7M8h9K6HuOBF3ASVyI,35697
88
+ topologicpy-0.4.83.dist-info/METADATA,sha256=wXCjKPnzNnIzC1Z_5o0cYk49HHe5ZWX6x5kZfu_PZew,7252
89
+ topologicpy-0.4.83.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
90
+ topologicpy-0.4.83.dist-info/top_level.txt,sha256=J30bDzW92Ob7hw3zA8V34Jlp-vvsfIkGzkr8sqvb4Uw,12
91
+ topologicpy-0.4.83.dist-info/RECORD,,