topologicpy 0.7.15__py3-none-any.whl → 0.7.17__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
@@ -152,10 +152,10 @@ class WorkerProcess(Process):
152
152
  destinations = [Topology.ByBREPString(s) for s in self.destinations]
153
153
  for i in range(len(sources)):
154
154
  source = sources[i]
155
- index_b = Vertex.Index(source, destinations)
155
+ index_b = Vertex.Index(source, destinations, tolerance=self.tolerance)
156
156
  for j in range(len(destinations)):
157
157
  destination = destinations[j]
158
- index_a = Vertex.Index(destination, sources)
158
+ index_a = Vertex.Index(destination, sources, tolerance=self.tolerance)
159
159
  if self.used[i + self.start_index][j] == 1 or self.used[j][i + self.start_index]:
160
160
  continue
161
161
  if Vertex.Distance(source, destination) > self.tolerance:
@@ -279,13 +279,13 @@ class Graph:
279
279
  graph : topologic_core.Graph
280
280
  The input graph.
281
281
  vertexKey : str , optional
282
- If set, the returned list of vertices is sorted according to the dicitonary values stored under this key. The default is None.
282
+ If set, the returned list of vertices is sorted according to the dictionary values stored under this key. The default is None.
283
283
  reverse : bool , optional
284
284
  If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. The default is False.
285
285
  edgeKeyFwd : str , optional
286
- If set, the value at this key in the connecting edge from start vertex to end verrtex (forward) will be used instead of the value 1. The default is None. useEdgeIndex and useEdgeLength override this setting.
286
+ If set, the value at this key in the connecting edge from start vertex to end vertex (forward) will be used instead of the value 1. The default is None. useEdgeIndex and useEdgeLength override this setting.
287
287
  edgeKeyBwd : str , optional
288
- If set, the value at this key in the connecting edge from end vertex to start verrtex (backward) will be used instead of the value 1. The default is None. useEdgeIndex and useEdgeLength override this setting.
288
+ If set, the value at this key in the connecting edge from end vertex to start vertex (backward) will be used instead of the value 1. The default is None. useEdgeIndex and useEdgeLength override this setting.
289
289
  bidirKey : bool , optional
290
290
  If set to True or False, this key in the connecting edge will be used to determine is the edge is supposed to be bidirectional or not. If set to None, the input variable bidrectional will be used instead. The default is None
291
291
  bidirectional : bool , optional
@@ -363,9 +363,10 @@ class Graph:
363
363
  if useEdgeLength:
364
364
  valueFwd = Edge.Length(edge)
365
365
  valueBwd = Edge.Length(edge)
366
- matrix[svi][evi] = valueFwd
367
- if bidir:
368
- matrix[evi][svi] = valueBwd
366
+ if not svi == None and not evi == None:
367
+ matrix[svi][evi] = valueFwd
368
+ if bidir:
369
+ matrix[evi][svi] = valueBwd
369
370
  return matrix
370
371
 
371
372
  @staticmethod
@@ -378,7 +379,7 @@ class Graph:
378
379
  graph : topologic_core.Graph
379
380
  The input graph.
380
381
  vertexKey : str , optional
381
- If set, the returned list of vertices is sorted according to the dicitonary values stored under this key. The default is None.
382
+ If set, the returned list of vertices is sorted according to the dictionary values stored under this key. The default is None.
382
383
  reverse : bool , optional
383
384
  If set to True, the vertices are sorted in reverse order (only if vertexKey is set). Otherwise, they are not. The default is False.
384
385
  tolerance : float , optional
@@ -433,7 +434,7 @@ class Graph:
433
434
  edge : topologic_core.Edge
434
435
  The input edge.
435
436
  transferDictionaries : bool, optional
436
- If set to True, the dictionaries of the edge and its vertices are transfered to the graph.
437
+ If set to True, the dictionaries of the edge and its vertices are transferred to the graph.
437
438
  tolerance : float , optional
438
439
  The desired tolerance. The default is 0.0001.
439
440
 
@@ -1521,7 +1522,7 @@ class Graph:
1521
1522
  edgeFeaturesHeader : str , optional
1522
1523
  The column header string used to specify the features of edges. The default is "feat".
1523
1524
  edgeFeaturesKeys : list , optional
1524
- The list of dicitonary keys to use to index the edge features. The length of this list must match the length of edge features. The default is [].
1525
+ The list of dictionary keys to use to index the edge features. The length of this list must match the length of edge features. The default is [].
1525
1526
  nodeIDHeader : str , optional
1526
1527
  The column header string used to specify the id of nodes. The default is "node_id".
1527
1528
  nodeLabelHeader : str , optional
@@ -1898,7 +1899,11 @@ class Graph:
1898
1899
 
1899
1900
 
1900
1901
  @staticmethod
1901
- def ByIFCFile(file, includeTypes=[], excludeTypes=[], includeRels=[], excludeRels=[], xMin=-0.5, yMin=-0.5, zMin=-0.5, xMax=0.5, yMax=0.5, zMax=0.5):
1902
+ def ByIFCFile(file, includeTypes: list = [], excludeTypes: list = [],
1903
+ includeRels: list = [], excludeRels: list = [],
1904
+ xMin: float = -0.5, yMin: float = -0.5, zMin: float = -0.5,
1905
+ xMax: float = 0.5, yMax: float = 0.5, zMax: float = 0.5,
1906
+ tolerance: float = 0.0001):
1902
1907
  """
1903
1908
  Create a Graph from an IFC file. This code is partially based on code from Bruno Postle.
1904
1909
 
@@ -1926,6 +1931,8 @@ class Graph:
1926
1931
  The desired maximum value to assign for a vertex's Y coordinate. The default is 0.5.
1927
1932
  zMax : float, optional
1928
1933
  The desired maximum value to assign for a vertex's Z coordinate. The default is 0.5.
1934
+ tolerance : float , optional
1935
+ The desired tolerance. The default is 0.0001.
1929
1936
 
1930
1937
  Returns
1931
1938
  -------
@@ -2094,19 +2101,21 @@ class Graph:
2094
2101
  if source:
2095
2102
  sv = vertexAtKeyValue(vertices, key="id", value=source.id())
2096
2103
  if sv:
2097
- si = Vertex.Index(sv, vertices)
2098
- for destination in destinations:
2099
- if destination == None:
2100
- continue
2101
- ev = vertexAtKeyValue(vertices, key="id", value=destination.id())
2102
- if ev:
2103
- ei = Vertex.Index(ev, vertices)
2104
- if not([si,ei] in tuples or [ei,si] in tuples):
2105
- tuples.append([si,ei])
2106
- e = Edge.ByVertices([sv,ev])
2107
- d = Dictionary.ByKeysValues(["id", "name", "type"], [ifc_rel.id(), ifc_rel.Name, ifc_rel.is_a()])
2108
- e = Topology.SetDictionary(e, d)
2109
- edges.append(e)
2104
+ si = Vertex.Index(sv, vertices, tolerance=tolerance)
2105
+ if not si == None:
2106
+ for destination in destinations:
2107
+ if destination == None:
2108
+ continue
2109
+ ev = vertexAtKeyValue(vertices, key="id", value=destination.id())
2110
+ if ev:
2111
+ ei = Vertex.Index(ev, vertices, tolerance=tolerance)
2112
+ if not ei == None:
2113
+ if not([si,ei] in tuples or [ei,si] in tuples):
2114
+ tuples.append([si,ei])
2115
+ e = Edge.ByVertices([sv,ev])
2116
+ d = Dictionary.ByKeysValues(["id", "name", "type"], [ifc_rel.id(), ifc_rel.Name, ifc_rel.is_a()])
2117
+ e = Topology.SetDictionary(e, d)
2118
+ edges.append(e)
2110
2119
  return edges
2111
2120
 
2112
2121
  ifc_types = IFCObjectTypes(file)
@@ -4811,7 +4820,7 @@ class Graph:
4811
4820
  nodeTrainMaskHeader="train_mask", nodeValidateMaskHeader="val_mask", nodeTestMaskHeader="test_mask",
4812
4821
  nodeMaskKey=None,
4813
4822
  nodeTrainRatio=0.8, nodeValidateRatio=0.1, nodeTestRatio=0.1,
4814
- mantissa=6, overwrite=False):
4823
+ mantissa=6, tolerance=0.0001, overwrite=False):
4815
4824
  """
4816
4825
  Exports the input graph into a set of CSV files compatible with DGL.
4817
4826
 
@@ -4894,6 +4903,8 @@ class Graph:
4894
4903
  This value is ignored if an nodeMaskKey is foud.
4895
4904
  mantissa : int , optional
4896
4905
  The desired length of the mantissa. The default is 6.
4906
+ tolerance : float , optional
4907
+ The desired tolerance. The default is 0.0001.
4897
4908
  overwrite : bool , optional
4898
4909
  If set to True, any existing files are overwritten. Otherwise, the input list of graphs is appended to the end of each file. The default is False.
4899
4910
 
@@ -5138,14 +5149,15 @@ class Graph:
5138
5149
  else:
5139
5150
  edge_features = str(round(float(Dictionary.ValueAtKey(ed, edge_feature_key)), mantissa))
5140
5151
  # Get the Source and Destination vertex indices
5141
- src = Vertex.Index(Edge.StartVertex(edge), vertices)
5142
- dst = Vertex.Index(Edge.EndVertex(edge), vertices)
5143
- single_edge_data = [graph_id, src, dst, edge_label, train_mask, validate_mask, test_mask, edge_features]
5144
- edge_data.append(single_edge_data)
5145
-
5146
- if bidirectional == True:
5152
+ src = Vertex.Index(Edge.StartVertex(edge), vertices, tolerance=tolerance)
5153
+ dst = Vertex.Index(Edge.EndVertex(edge), vertices, tolerance=tolerance)
5154
+ if not src == None and not dst == None:
5147
5155
  single_edge_data = [graph_id, src, dst, edge_label, train_mask, validate_mask, test_mask, edge_features]
5148
5156
  edge_data.append(single_edge_data)
5157
+
5158
+ if bidirectional == True:
5159
+ single_edge_data = [graph_id, src, dst, edge_label, train_mask, validate_mask, test_mask, edge_features]
5160
+ edge_data.append(single_edge_data)
5149
5161
  df = pd.DataFrame(edge_data, columns=edge_columns)
5150
5162
 
5151
5163
  if graph_id == 0:
@@ -5167,7 +5179,8 @@ class Graph:
5167
5179
  defaultVertexColor: str = "black", defaultVertexSize: float = 3,
5168
5180
  vertexLabelKey: str = None, vertexColorKey: str = None, vertexSizeKey: str = None,
5169
5181
  defaultEdgeColor: str = "black", defaultEdgeWeight: float = 1, defaultEdgeType: str = "undirected",
5170
- edgeLabelKey: str = None, edgeColorKey: str = None, edgeWeightKey: str = None, overwrite: bool = False, mantissa: int = 6):
5182
+ edgeLabelKey: str = None, edgeColorKey: str = None, edgeWeightKey: str = None,
5183
+ overwrite: bool = False, mantissa: int = 6, tolerance: float = 0.0001):
5171
5184
  """
5172
5185
  Exports the input graph to a Graph Exchange XML (GEXF) file format. See https://gexf.net/
5173
5186
 
@@ -5215,6 +5228,8 @@ class Graph:
5215
5228
  If set to True, any existing file is overwritten. Otherwise, it is not. The default is False.
5216
5229
  mantissa : int , optional
5217
5230
  The desired length of the mantissa. The default is 6.
5231
+ tolerance : float , optional
5232
+ The desired tolerance. The default is 0.0001.
5218
5233
 
5219
5234
  Returns
5220
5235
  -------
@@ -5487,20 +5502,20 @@ class Graph:
5487
5502
  edge_dict['weight'] = edge_weight
5488
5503
 
5489
5504
 
5490
- sv = g_vertices[Vertex.Index(Edge.StartVertex(edge), g_vertices)]
5491
- ev = g_vertices[Vertex.Index(Edge.EndVertex(edge), g_vertices)]
5492
- svid = Vertex.Index(sv, g_vertices)
5493
- edge_dict['source'] = svid
5494
- evid = Vertex.Index(ev, g_vertices)
5495
- edge_dict['target'] = evid
5496
-
5497
- edge_label = "Edge "+str(svid)+"-"+str(evid)
5498
- if isinstance(edgeLabelKey, str):
5499
- edge_label = Dictionary.ValueAtKey(d, edgeLabelKey)
5500
- if not isinstance(edge_label, str):
5505
+ sv = g_vertices[Vertex.Index(Edge.StartVertex(edge), g_vertices, tolerance=tolerance)]
5506
+ ev = g_vertices[Vertex.Index(Edge.EndVertex(edge), g_vertices, tolerance=tolerance)]
5507
+ svid = Vertex.Index(sv, g_vertices, tolerance=tolerance)
5508
+ evid = Vertex.Index(ev, g_vertices, tolerance=tolerance)
5509
+ if not svid == None and not evid == None:
5510
+ edge_dict['source'] = svid
5511
+ edge_dict['target'] = evid
5501
5512
  edge_label = "Edge "+str(svid)+"-"+str(evid)
5502
- edge_dict['label'] = edge_label
5503
- edges[(str(svid), str(evid))] = edge_dict
5513
+ if isinstance(edgeLabelKey, str):
5514
+ edge_label = Dictionary.ValueAtKey(d, edgeLabelKey)
5515
+ if not isinstance(edge_label, str):
5516
+ edge_label = "Edge "+str(svid)+"-"+str(evid)
5517
+ edge_dict['label'] = edge_label
5518
+ edges[(str(svid), str(evid))] = edge_dict
5504
5519
 
5505
5520
  create_gexf_file(nodes, edges, defaultEdgeType, node_attributes, edge_attributes, path)
5506
5521
  return True
@@ -5596,6 +5611,8 @@ class Graph:
5596
5611
  The desired maximum number of iterations to solve the forces in the 'spring' mode. The default is 50.
5597
5612
  rootVertex : topologic_core.Vertex , optional
5598
5613
  The desired vertex to use as the root of the tree and radial layouts.
5614
+ tolerance : float , optional
5615
+ The desired tolerance. The default is 0.0001.
5599
5616
 
5600
5617
  Returns
5601
5618
  -------
@@ -5725,9 +5742,12 @@ class Graph:
5725
5742
  Returns:
5726
5743
  A numpy array representing the adjacency matrix.
5727
5744
  """
5728
-
5745
+ from topologicpy.Helper import Helper
5729
5746
  # Get the number of nodes from the edge list.
5730
- num_nodes = max([max(edge) for edge in edge_list]) + 1
5747
+ flat_list = Helper.Flatten(edge_list)
5748
+ flat_list = [x for x in flat_list if not x == None]
5749
+ num_nodes = max(flat_list) + 1
5750
+ print("Number of Nodes:", num_nodes)
5731
5751
 
5732
5752
  # Create an adjacency matrix.
5733
5753
  adjacency_matrix = np.zeros((num_nodes, num_nodes))
@@ -5913,8 +5933,9 @@ class Graph:
5913
5933
  if rootVertex == None:
5914
5934
  rootVertex, root_index = vertex_max_degree(graph, vertices)
5915
5935
  else:
5916
- root_index = Vertex.Index(rootVertex, vertices)
5917
-
5936
+ root_index = Vertex.Index(rootVertex, vertices, tolerance=tolerance)
5937
+ if root_index == None:
5938
+ root_index = 0
5918
5939
  if 'rad' in layout.lower():
5919
5940
  positions = radial_layout(edges, root_index=root_index)
5920
5941
  elif 'spring' in layout.lower():
@@ -6248,7 +6269,8 @@ class Graph:
6248
6269
  yKey: str = "y",
6249
6270
  zKey: str = "z",
6250
6271
  geometryKey: str = "brep",
6251
- mantissa: int = 6):
6272
+ mantissa: int = 6,
6273
+ tolerance: float = 0.0001):
6252
6274
  """
6253
6275
  Converts the input graph into JSON data.
6254
6276
 
@@ -6280,6 +6302,8 @@ class Graph:
6280
6302
  The desired key name to use for geometry. The default is "brep".
6281
6303
  mantissa : int , optional
6282
6304
  The desired length of the mantissa. The default is 6.
6305
+ tolerance : float , optional
6306
+ The desired tolerance. The default is 0.0001.
6283
6307
 
6284
6308
  Returns
6285
6309
  -------
@@ -6329,22 +6353,23 @@ class Graph:
6329
6353
  for i, e in enumerate(edges):
6330
6354
  sv = Edge.StartVertex(e)
6331
6355
  ev = Edge.EndVertex(e)
6332
- svi = Vertex.Index(sv, vertices)
6333
- evi = Vertex.Index(ev, vertices)
6334
- sv_label = v_labels[svi]
6335
- ev_label = v_labels[evi]
6336
- d = Topology.Dictionary(e)
6337
-
6338
- d = Dictionary.SetValueAtKey(d, sourceKey, sv_label)
6339
- d = Dictionary.SetValueAtKey(d, targetKey, ev_label)
6340
- e_dict = Dictionary.PythonDictionary(d)
6341
- e_label = Dictionary.ValueAtKey(d, edgeLabelKey)
6342
- if isinstance(e_label, str):
6356
+ svi = Vertex.Index(sv, vertices, tolerance=tolerance)
6357
+ evi = Vertex.Index(ev, vertices, tolerance=tolerance)
6358
+ if not svi == None and not evi == None:
6359
+ sv_label = v_labels[svi]
6360
+ ev_label = v_labels[evi]
6361
+ d = Topology.Dictionary(e)
6362
+
6363
+ d = Dictionary.SetValueAtKey(d, sourceKey, sv_label)
6364
+ d = Dictionary.SetValueAtKey(d, targetKey, ev_label)
6365
+ e_dict = Dictionary.PythonDictionary(d)
6343
6366
  e_label = Dictionary.ValueAtKey(d, edgeLabelKey)
6344
- else:
6345
- e_label = "Edge_"+str(i).zfill(n)
6346
- e_labels.append(e_label)
6347
- e_dicts.append(e_dict)
6367
+ if isinstance(e_label, str):
6368
+ e_label = Dictionary.ValueAtKey(d, edgeLabelKey)
6369
+ else:
6370
+ e_label = "Edge_"+str(i).zfill(n)
6371
+ e_labels.append(e_label)
6372
+ e_dicts.append(e_dict)
6348
6373
  e_labels = Helper.MakeUnique(e_labels)
6349
6374
  for i, e_label in enumerate(e_labels):
6350
6375
  j_data[edgesKey][e_label] = e_dicts[i]
@@ -6405,7 +6430,7 @@ class Graph:
6405
6430
  return json_string
6406
6431
 
6407
6432
  @staticmethod
6408
- def LocalClusteringCoefficient(graph, vertices=None, mantissa=6):
6433
+ def LocalClusteringCoefficient(graph, vertices: list = None, mantissa: int = 6, tolerance: float = 0.0001):
6409
6434
  """
6410
6435
  Returns the local clustering coefficient of the input list of vertices within the input graph. See https://en.wikipedia.org/wiki/Clustering_coefficient.
6411
6436
 
@@ -6414,9 +6439,11 @@ class Graph:
6414
6439
  graph : topologic_core.Graph
6415
6440
  The input graph.
6416
6441
  vertices : list , optional
6417
- The input list of vertices. If set to None, the local clustering coefficient of all vertices will be computed.
6442
+ The input list of vertices. If set to None, the local clustering coefficient of all vertices will be computed. The default is None.
6418
6443
  mantissa : int , optional
6419
6444
  The desired length of the mantissa. The default is 6.
6445
+ tolerance : float , optional
6446
+ The desired tolerance. The default is 0.0001.
6420
6447
 
6421
6448
  Returns
6422
6449
  -------
@@ -6470,7 +6497,7 @@ class Graph:
6470
6497
  adjacency_matrix = Graph.AdjacencyMatrix(graph)
6471
6498
  lcc = []
6472
6499
  for v in vertices:
6473
- i = Vertex.Index(v, g_vertices)
6500
+ i = Vertex.Index(v, g_vertices, tolerance=tolerance)
6474
6501
  if not i == None:
6475
6502
  lcc.append(round(local_clustering_coefficient(adjacency_matrix, i), mantissa))
6476
6503
  else:
@@ -6556,9 +6583,10 @@ class Graph:
6556
6583
  vertices = Topology.Vertices(path)
6557
6584
  pathCost = 0
6558
6585
  for vertex in vertices:
6559
- index = Vertex.Index(vertex, g_vertices)
6560
- d = Topology.Dictionary(g_vertices[index])
6561
- value = Dictionary.ValueAtKey(d, vertexKey)
6586
+ index = Vertex.Index(vertex, g_vertices, tolerance=tolerance)
6587
+ if not index == None:
6588
+ d = Topology.Dictionary(g_vertices[index])
6589
+ value = Dictionary.ValueAtKey(d, vertexKey)
6562
6590
  if not value == None:
6563
6591
  pathCost += value
6564
6592
  lengths[i] += pathCost
@@ -6697,29 +6725,31 @@ class Graph:
6697
6725
  edgeMatrix = Graph.AdjacencyMatrix(graph, edgeKeyFwd=edgeKeyFwd, edgeKeyBwd=edgeKeyBwd, bidirKey=bidirKey, bidirectional=bidirectional, useEdgeIndex = True, useEdgeLength=False, tolerance=tolerance)
6698
6726
  vertices = Graph.Vertices(graph)
6699
6727
  edges = Graph.Edges(graph)
6700
- sourceIndex = Vertex.Index(source, vertices)
6701
- sinkIndex = Vertex.Index(sink, vertices)
6702
- max_flow, am = ford_fulkerson(adjMatrix=adjMatrix, source=sourceIndex, sink=sinkIndex)
6703
- for i in range(len(am)):
6704
- row = am[i]
6705
- for j in range(len(row)):
6706
- residual = am[i][j]
6707
- edge = edges[edgeMatrix[i][j]-1]
6708
- d = Topology.Dictionary(edge)
6709
- if not d == None:
6710
- keys = Dictionary.Keys(d)
6711
- values = Dictionary.Values(d)
6712
- else:
6713
- keys = []
6714
- values = []
6715
- keys.append(residualKey)
6716
- values.append(residual)
6717
- d = Dictionary.ByKeysValues(keys, values)
6718
- edge = Topology.SetDictionary(edge, d)
6728
+ sourceIndex = Vertex.Index(source, vertices, tolerance=tolerance)
6729
+ sinkIndex = Vertex.Index(sink, vertices, tolerance=tolerance)
6730
+ max_flow = None
6731
+ if not sourceIndex == None and not sinkIndex == None:
6732
+ max_flow, am = ford_fulkerson(adjMatrix=adjMatrix, source=sourceIndex, sink=sinkIndex)
6733
+ for i in range(len(am)):
6734
+ row = am[i]
6735
+ for j in range(len(row)):
6736
+ residual = am[i][j]
6737
+ edge = edges[edgeMatrix[i][j]-1]
6738
+ d = Topology.Dictionary(edge)
6739
+ if not d == None:
6740
+ keys = Dictionary.Keys(d)
6741
+ values = Dictionary.Values(d)
6742
+ else:
6743
+ keys = []
6744
+ values = []
6745
+ keys.append(residualKey)
6746
+ values.append(residual)
6747
+ d = Dictionary.ByKeysValues(keys, values)
6748
+ edge = Topology.SetDictionary(edge, d)
6719
6749
  return max_flow
6720
6750
 
6721
6751
  @staticmethod
6722
- def MeshData(g):
6752
+ def MeshData(g, tolerance: float = 0.0001):
6723
6753
  """
6724
6754
  Returns the mesh data of the input graph.
6725
6755
 
@@ -6727,6 +6757,8 @@ class Graph:
6727
6757
  ----------
6728
6758
  graph : topologic_core.Graph
6729
6759
  The input graph.
6760
+ tolerance : float , optional
6761
+ The desired tolerance. The default is 0.0001.
6730
6762
 
6731
6763
  Returns
6732
6764
  -------
@@ -6755,11 +6787,12 @@ class Graph:
6755
6787
  for g_edge in g_edges:
6756
6788
  sv = g_edge.StartVertex()
6757
6789
  ev = g_edge.EndVertex()
6758
- si = Vertex.Index(sv, g_vertices)
6759
- ei = Vertex.Index(ev, g_vertices)
6760
- m_edges.append([si, ei])
6761
- d = Dictionary.PythonDictionary(Topology.Dictionary(g_edge))
6762
- e_dicts.append(d)
6790
+ si = Vertex.Index(sv, g_vertices, tolerance=tolerance)
6791
+ ei = Vertex.Index(ev, g_vertices, tolerance=tolerance)
6792
+ if (not si == None) and (not ei == None):
6793
+ m_edges.append([si, ei])
6794
+ d = Dictionary.PythonDictionary(Topology.Dictionary(g_edge))
6795
+ e_dicts.append(d)
6763
6796
  return {'vertices':m_vertices,
6764
6797
  'edges': m_edges,
6765
6798
  'vertexDictionaries': v_dicts,
@@ -7231,7 +7264,9 @@ class Graph:
7231
7264
  incoming_score = 0
7232
7265
  for incoming_vertex in Graph.IncomingVertices(graph, vertex, directed=directed):
7233
7266
  if len(Graph.IncomingVertices(graph, incoming_vertex, directed=directed)) > 0:
7234
- incoming_score += scores[Vertex.Index(incoming_vertex, vertices)] / len(Graph.IncomingVertices(graph, incoming_vertex, directed=directed))
7267
+ vi = Vertex.Index(incoming_vertex, vertices, tolerance=tolerance)
7268
+ if not vi == None:
7269
+ incoming_score += scores[vi] / len(Graph.IncomingVertices(graph, incoming_vertex, directed=directed))
7235
7270
  new_scores[i] = alpha * incoming_score + (1 - alpha) / num_vertices
7236
7271
 
7237
7272
  # Check for convergence
@@ -7286,9 +7321,14 @@ class Graph:
7286
7321
 
7287
7322
 
7288
7323
  @staticmethod
7289
- def PyvisGraph(graph, path, overwrite=True, height=900, backgroundColor="white", fontColor="black", notebook=False,
7290
- vertexSize=6, vertexSizeKey=None, vertexColor="black", vertexColorKey=None, vertexLabelKey=None, vertexGroupKey=None, vertexGroups=None, minVertexGroup=None, maxVertexGroup=None,
7291
- edgeLabelKey=None, edgeWeight=0, edgeWeightKey=None, showNeighbours=True, selectMenu=True, filterMenu=True, colorScale="viridis"):
7324
+ def PyvisGraph(graph, path, overwrite: bool = True, height: int = 900, backgroundColor: str = "white",
7325
+ fontColor: str = "black", notebook: bool = False,
7326
+ vertexSize: int = 6, vertexSizeKey: str = None, vertexColor: str = "black",
7327
+ vertexColorKey: str = None, vertexLabelKey: str = None, vertexGroupKey: str = None,
7328
+ vertexGroups: list = None, minVertexGroup: float = None, maxVertexGroup: float = None,
7329
+ edgeLabelKey: str = None, edgeWeight: int = 0, edgeWeightKey: str = None,
7330
+ showNeighbours: bool = True, selectMenu: bool = True,
7331
+ filterMenu: bool = True, colorScale: str = "viridis", tolerance: float = 0.0001):
7292
7332
  """
7293
7333
  Displays a pyvis graph. See https://pyvis.readthedocs.io/.
7294
7334
 
@@ -7341,7 +7381,8 @@ class Graph:
7341
7381
  If set to True, a filtering menu will be displayed. The default is True.
7342
7382
  colorScale : str , optional
7343
7383
  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/.
7344
-
7384
+ tolerance : float , optional
7385
+ The desired tolerance. The default is 0.0001.
7345
7386
  Returns
7346
7387
  -------
7347
7388
  None
@@ -7367,7 +7408,7 @@ class Graph:
7367
7408
  from pyvis.network import Network
7368
7409
  print("Graph.PyvisGraph - Information: pyvis library installed correctly.")
7369
7410
  except:
7370
- warnings.warn("Graph - Error: Could not import pyvis. Please try to install pyvis manually. Retruning None.")
7411
+ warnings.warn("Graph - Error: Could not import pyvis. Please try to install pyvis manually. Returning None.")
7371
7412
  return None
7372
7413
 
7373
7414
  net = Network(height=str(height)+"px", width="100%", bgcolor=backgroundColor, font_color=fontColor, select_menu=selectMenu, filter_menu=filterMenu, cdn_resources="remote", notebook=notebook)
@@ -7443,9 +7484,10 @@ class Graph:
7443
7484
  w = weightValue
7444
7485
  sv = Edge.StartVertex(e)
7445
7486
  ev = Edge.EndVertex(e)
7446
- svi = Vertex.Index(sv, vertices)
7447
- evi = Vertex.Index(ev, vertices)
7448
- net.add_edge(svi, evi, weight=w, label=edge_label)
7487
+ svi = Vertex.Index(sv, vertices, tolerance=tolerance)
7488
+ evi = Vertex.Index(ev, vertices, tolerance=tolerance)
7489
+ if (not svi == None) and (not evi == None):
7490
+ net.add_edge(svi, evi, weight=w, label=edge_label)
7449
7491
  net.inherit_edge_colors(False)
7450
7492
 
7451
7493
  # add neighbor data to node hover data and compute vertexSize
topologicpy/Neo4j.py CHANGED
@@ -339,8 +339,8 @@ class Neo4j:
339
339
  e = edges[i]
340
340
  sv = e.StartVertex()
341
341
  ev = e.EndVertex()
342
- sn = nodes[Vertex.Index(sv, vertices, tolerance)]
343
- en = nodes[Vertex.Index(ev, vertices, tolerance)]
342
+ sn = nodes[Vertex.Index(sv, vertices, tolerance=tolerance)]
343
+ en = nodes[Vertex.Index(ev, vertices, tolerance=tolerance)]
344
344
  relationshipType = Dictionary.ValueAtKey(e, relationshipKey)
345
345
  if not (relationshipType):
346
346
  relationshipType = "Connected To"
topologicpy/Shell.py CHANGED
@@ -331,6 +331,52 @@ class Shell():
331
331
  _ = cluster.Faces(None, faces)
332
332
  return Shell.ByFaces(faces, tolerance=tolerance)
333
333
 
334
+
335
+ @staticmethod
336
+ def ByThickenedWire(wire, offsetA: float = 1.0, offsetB: float = 1.0, tolerance: float = 0.0001):
337
+ """
338
+ Creates a shell by thickening the input wire. This method assumes the wire is manifold and planar.
339
+
340
+ Parameters
341
+ ----------
342
+ wire : topologic_core.Wire
343
+ The input wire to be thickened.
344
+ offsetA : float , optional
345
+ The desired offset to the exterior of the wire. The default is 1.0.
346
+ offsetB : float , optional
347
+ The desired offset to the interior of the wire. The default is 1.0.
348
+ tolerance : float , optional
349
+ The desired tolerance. The default is 0.0001.
350
+
351
+ Returns
352
+ -------
353
+ topologic_core.Cell
354
+ The created cell.
355
+
356
+ """
357
+ from topologicpy.Edge import Edge
358
+ from topologicpy.Wire import Wire
359
+ from topologicpy.Face import Face
360
+ from topologicpy.Topology import Topology
361
+
362
+ if not Topology.IsInstance(wire, "Wire"):
363
+ print("Shell.ByThickenedWire - Error: The input wire parameter is not a valid wire. Returning None.")
364
+ return None
365
+
366
+ f = Face.ByThickenedWire(wire, offsetA=offsetA, offsetB=offsetB, tolerance=tolerance)
367
+ outside_wire = Wire.ByOffset(wire, offset=abs(offsetA)*-1, bisectors = False, tolerance=tolerance)
368
+ inside_wire = Wire.ByOffset(wire, offset=abs(offsetB), bisectors = False, tolerance=tolerance)
369
+ border = Topology.Merge(outside_wire, inside_wire)
370
+ outside_wire = Wire.ByOffset(wire, offset=abs(offsetA)*-1, bisectors = True, tolerance=tolerance)
371
+ inside_wire = Wire.ByOffset(wire, offset=abs(offsetB), bisectors = True, tolerance=tolerance)
372
+ grid = Topology.Merge(outside_wire, inside_wire)
373
+ bisectors = Topology.Difference(grid, border)
374
+ return_shell = Topology.Slice(f, bisectors)
375
+ if not Topology.IsInstance(return_shell, "Shell"):
376
+ print("Shell.ByThickenedWire - Error: The operation failed. Returning None.")
377
+ return None
378
+ return return_shell
379
+
334
380
  @staticmethod
335
381
  def ByWires(wires: list, triangulate: bool = True, tolerance: float = 0.0001, silent: bool = False):
336
382
  """
@@ -708,23 +754,23 @@ class Shell():
708
754
  Parameters
709
755
  ----------
710
756
  origin : topologic_core.Vertex , optional
711
- The origin of the hyperbolic parabolid. If set to None, it will be placed at the (0, 0, 0) origin. The default is None.
757
+ The origin of the hyperbolic paraboloid. If set to None, it will be placed at the (0, 0, 0) origin. The default is None.
712
758
  llVertex : topologic_core.Vertex , optional
713
- The lower left corner of the hyperbolic parabolid. If set to None, it will be set to (-0.5, -0.5, -0.5).
759
+ The lower left corner of the hyperbolic paraboloid. If set to None, it will be set to (-0.5, -0.5, -0.5).
714
760
  lrVertex : topologic_core.Vertex , optional
715
- The lower right corner of the hyperbolic parabolid. If set to None, it will be set to (0.5, -0.5, 0.5).
761
+ The lower right corner of the hyperbolic paraboloid. If set to None, it will be set to (0.5, -0.5, 0.5).
716
762
  ulVertex : topologic_core.Vertex , optional
717
- The upper left corner of the hyperbolic parabolid. If set to None, it will be set to (-0.5, 0.5, 0.5).
763
+ The upper left corner of the hyperbolic paraboloid. If set to None, it will be set to (-0.5, 0.5, 0.5).
718
764
  urVertex : topologic_core.Vertex , optional
719
- The upper right corner of the hyperbolic parabolid. If set to None, it will be set to (0.5, 0.5, -0.5).
765
+ The upper right corner of the hyperbolic paraboloid. If set to None, it will be set to (0.5, 0.5, -0.5).
720
766
  uSides : int , optional
721
767
  The number of segments along the X axis. The default is 10.
722
768
  vSides : int , optional
723
769
  The number of segments along the Y axis. The default is 10.
724
770
  direction : list , optional
725
- The vector representing the up direction of the hyperbolic parabolid. The default is [0, 0, 1].
771
+ The vector representing the up direction of the hyperbolic paraboloid. The default is [0, 0, 1].
726
772
  placement : str , optional
727
- The description of the placement of the origin of the hyperbolic parabolid. This can be "center", "lowerleft", "bottom". It is case insensitive. The default is "center".
773
+ The description of the placement of the origin of the hyperbolic paraboloid. This can be "center", "lowerleft", "bottom". It is case insensitive. The default is "center".
728
774
  mantissa : int , optional
729
775
  The desired length of the mantissa. The default is 6.
730
776
  tolerance : float , optional
@@ -827,7 +873,7 @@ class Shell():
827
873
  Returns
828
874
  -------
829
875
  topologic_core.Shell
830
- The created hyperboloic paraboloid.
876
+ The created hyperbolic paraboloid.
831
877
 
832
878
  """
833
879
  from topologicpy.Vertex import Vertex
@@ -1287,7 +1333,7 @@ class Shell():
1287
1333
  The desired angle in degrees of the roof. The default is 45.
1288
1334
  epsilon : float , optional
1289
1335
  The desired epsilon (another form of tolerance for distance from plane). The default is 0.01. (This is set to a larger number as it was found to work better)
1290
- manitssa : int , optional
1336
+ mantissa : int , optional
1291
1337
  The desired length of the mantissa. The default is 6.
1292
1338
  tolerance : float , optional
1293
1339
  The desired tolerance. The default is 0.001. (This is set to a larger number as it was found to work better)
@@ -1495,7 +1541,7 @@ class Shell():
1495
1541
  @staticmethod
1496
1542
  def Simplify(shell, simplifyBoundary: bool = True, mantissa: int = 6, tolerance: float = 0.0001):
1497
1543
  """
1498
- Simplifies the input shell edges based on the Douglas Peucker algorthim. See https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
1544
+ Simplifies the input shell edges based on the Douglas Peucker algorithm. See https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
1499
1545
  Part of this code was contributed by gaoxipeng. See https://github.com/wassimj/topologicpy/issues/35
1500
1546
 
1501
1547
  Parameters
@@ -1765,7 +1811,7 @@ class Shell():
1765
1811
  for v in tempWire:
1766
1812
  if len(temp_verts) == 0:
1767
1813
  temp_verts.append(v)
1768
- elif Vertex.Index(v, temp_verts) == None:
1814
+ elif Vertex.Index(v, temp_verts, tolerance=tolerance) == None:
1769
1815
  temp_verts.append(v)
1770
1816
  tempWire = temp_verts
1771
1817
  temp_w = Wire.ByVertices(tempWire, close=True)