-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from AlainKadar/compute_api
Compute API
- Loading branch information
Showing
68 changed files
with
1,747 additions
and
1,478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from StructuralGT import networks | ||
import numpy as np | ||
from StructuralGT.electronic import Electronic | ||
from StructuralGT.structural import Structural | ||
|
||
options = {"Thresh_method":0, "gamma": 3, "md_filter": 0, "g_blur": 1, | ||
"autolvl": 0,"fg_color":0,"laplacian": 0, "scharr": 0, "sobel":0 , | ||
"lowpass": 1, "asize":7, "bsize":3, "wsize":5, "thresh": 103} | ||
|
||
ANF = networks.Network('ANF') | ||
ANF.binarize(options_dict=options) | ||
ANF.img_to_skel(crop=[200,300,200,300], rotate=45, merge_nodes=5, remove_objects=10) | ||
ANF.set_graph(weight_type=['FixedWidthConductance'], rho_dim=1, R_j=12, sub=True) | ||
|
||
S = Structural() | ||
S.compute(ANF) | ||
print(S.diameter) | ||
|
||
E = Electronic() | ||
E.compute(ANF, 0, 0, [[0,50],[350,400]]) | ||
print(E.effective_resistance) | ||
|
||
|
||
print(ANF.graph.transitivity_undirected()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from StructuralGT.util import _Compute | ||
import numpy as np | ||
import copy | ||
from StructuralGT import _average_nodal_connectivity_cast | ||
|
||
class AverageNodalConnectivity(_Compute): | ||
"""A module solely for calculating the average nodal connectivity. | ||
Written separately because it is computationally very expensive, yet has | ||
been shown to correlate well with material properties.REF | ||
""" | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
def compute(self, network): | ||
"""Computes the average nodal connectivity.""" | ||
_copy = copy.deepcopy(network.graph) | ||
|
||
cast = _average_nodal_connectivity_cast.PyCast(_copy._raw_pointer()) | ||
|
||
cast.average_nodal_connectivity_compute() | ||
|
||
self._average_nodal_connectivity = cast.average_nodal_connectivity | ||
|
||
@_Compute._computed_property | ||
def average_nodal_connectivity(self): | ||
r"""The nodal connectivity $\kappa(i,j)$, is the minimum number of edges | ||
that would need to be removed to disconnect nodes $i$ and $j$. The | ||
average nodal connectivity is the connectivity value averaged over all | ||
pairs of nodes: | ||
.. math:: | ||
\bar{\kappa} = 2\frac{\sum_{i \neq j}\kappa(i,j)}{n(n-1)} | ||
""" | ||
return self._average_nodal_connectivity |
Oops, something went wrong.