diff options
author | Paula PĂ©rez Bianchi <44149844+paulitapb@users.noreply.github.com> | 2022-10-31 18:57:13 -0300 |
---|---|---|
committer | Jarrod Millman <jarrod.millman@gmail.com> | 2022-11-01 10:28:59 -0700 |
commit | c817a800f748fe3653913b264fcd4fdab66c030a (patch) | |
tree | 59ca5ac18c8fb4e329b23da5771e1dcb0c774dfb | |
parent | a130cb6f4c1727b0caf71776f61e557546ff179f (diff) | |
download | networkx-c817a800f748fe3653913b264fcd4fdab66c030a.tar.gz |
Add example for fiedler_vector (#6155)
* Added axample for fiedler_vector
Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
-rw-r--r-- | networkx/linalg/algebraicconnectivity.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/networkx/linalg/algebraicconnectivity.py b/networkx/linalg/algebraicconnectivity.py index 9a7fe8cd..b1b9ef6e 100644 --- a/networkx/linalg/algebraicconnectivity.py +++ b/networkx/linalg/algebraicconnectivity.py @@ -460,6 +460,18 @@ def fiedler_vector( See Also -------- laplacian_matrix + + Examples + -------- + Given a connected graph the signs of the values in the Fiedler vector can be + used to partition the graph into two components. + + >>> G = nx.barbell_graph(5, 0) + >>> nx.fiedler_vector(G, normalized=True, seed=1) + array([-0.32864129, -0.32864129, -0.32864129, -0.32864129, -0.26072899, + 0.26072899, 0.32864129, 0.32864129, 0.32864129, 0.32864129]) + + The connected components are the two 5-node cliques of the barbell graph. """ import numpy as np |