Skip to content

Commit

Permalink
Add structural module
Browse files Browse the repository at this point in the history
  • Loading branch information
AlainKadar committed Nov 3, 2023
1 parent 8a75dc8 commit 9536986
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions StructuralGT/structural.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from StructuralGT.util import _Compute

class Structural(_Compute):
"""Classical GT parameters. Calculates most of the parameters offered
by the StructuralGT GUI :cite:`Vecchio2021`.
"""
def __init__(self):
pass

def compute(self, network, skips=None):
operations = [
network.graph.diameter,
network.graph.density,
network.graph.transitivity_undirected,
network.graph.assortativity_degree,
network.graph.betweenness,
network.graph.closeness,
network.graph.degree,
]

names = [
"Diameter",
"Density",
"Clustering",
"Degree_Assortativity",
"Betweenness",
"Closeness",
"Degree"
]

for operation, name in zip(operations, names):
setattr(self, name, operation())

@_Compute._computed_property
def diameter(self):
"""The maximum number of edges that have to be traversed to get from
one node to any other node. Also referred to as the maximum
eccentricity, or the longest-shortest path of the graph.
"""
return self.Diameter

@_Compute._computed_property
def density(self):
r"""float: The fraction of edges that exist compared to all possible
edges in a complete graph:
.. math::
\rho = \frac{2e}{n(n-1)}
"""
return self.Density

@_Compute._computed_property
def clustering(self):

r"""float: fraction of neighbors of a node that are directly connected to each other as well (forming a triangle). Ti is the number of connected triples (visually triangles) on node i.
"""
return self.Clustering

@_Compute._computed_property
def diameter(self):
return self.Diameter
@_Compute._computed_property
def diameter(self):
return self.Diameter
@_Compute._computed_property
def diameter(self):
return self.Diameter
@_Compute._computed_property
def diameter(self):
return self.Diameter

@_Compute._computed_property
def diameter(self):
return self.Diameter
@_Compute._computed_property
def diameter(self):
return self.Diameter
@_Compute._computed_property
def diameter(self):
return self.Diameter
@_Compute._computed_property
def diameter(self):
return self.Diameter
@_Compute._computed_property
def diameter(self):
return self.Diameter

0 comments on commit 9536986

Please sign in to comment.