Classic
These functions are classic graph theoretic metrics.
ccc(matrix)
Computes the classical clustering coefficient of a directed graph
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix |
numpy array
|
the adjaceny matrix of a directed graph |
required |
Returns:
Type | Description |
---|---|
float
|
the clustering coefficient |
References
The formula is taken from the following paper.
..[1] G. Fagiolo, "Clustering in complex directed networks", 2006; DOI: 10.1103/PhysRevE.76.026107.
Source code in src/connalysis/network/classic.py
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
|
centrality(self, sub_gids, kind='closenesgit rebases', directed=False)
Compute a centrality of the graph. kind
can be 'betweeness' or 'closeness'
Source code in src/connalysis/network/classic.py
68 69 70 71 72 73 |
|
closeness(adj, neuron_properties, directed=False)
Compute closeness centrality using sknetwork on all connected components or strongly connected component (if directed==True)
Source code in src/connalysis/network/classic.py
63 64 65 66 |
|
closeness_connected_components(adj, neuron_properties=[], directed=False, return_sum=True)
Compute the closeness of each connected component of more than 1 vertex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adj |
array_like
|
Adjacency matrix of the graph |
required |
directed |
bool
|
If |
False
|
return_sum |
bool
|
If |
True
|
Returns:
Type | Description |
---|---|
array_like
|
A single array( if |
Source code in src/connalysis/network/classic.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
connected_components(adj, neuron_properties=[])
Returns a list of the size of the connected components of the underlying undirected graph on sub_gids, if None, compute on the whole graph
Source code in src/connalysis/network/classic.py
76 77 78 79 80 81 82 83 84 |
|
core_number(adj, neuron_properties=[])
Returns k core of directed graph, where degree of a vertex is the sum of in degree and out degree
Source code in src/connalysis/network/classic.py
86 87 88 89 90 91 |
|
generate_degree_based_control(M, direction='efferent')
A shuffled version of a connectivity matrix that aims to preserve degree distributions. If direction = "efferent", then the out-degree is exactly preserved, while the in-degree is approximately preseved. Otherwise it's the other way around.
Source code in src/connalysis/network/classic.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
largest_strongly_connected_component(adjacency_matrix)
Computes the largest strongly connected component of the graph with adjacency matrix adjacency_matrix, and returns the adjacency matrix of said component
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adjacency_matrix |
numpy array
|
the adjaceny matrix of the DiGraph as a numpy array |
required |
Returns:
Type | Description |
---|---|
numpy array
|
The adjacency matrix of the largest strongly connected component |
Source code in src/connalysis/network/classic.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
|
np_to_nx(adjacency_matrix)
Converts numpy array of an adjacency matrix to a networkx digraph
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adjacency_matrix |
numpy array
|
the adjaceny matrix of the DiGraph as a numpy array |
required |
Returns:
Type | Description |
---|---|
networkx DiGraph
|
a directed graph |
Source code in src/connalysis/network/classic.py
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
|
nx_to_np(directed_graph)
Converts networkx digraph to numpy array of the adjacency matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directed_graph |
networkx DiGraph
|
a directed graph |
required |
Returns:
Type | Description |
---|---|
numpy array
|
the adjaceny matrix of the DiGraph as a numpy array |
Source code in src/connalysis/network/classic.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|