-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d2f279
commit d1fb3e0
Showing
18 changed files
with
266 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Gallery of examples | ||
================== | ||
|
||
Introductory examples to XGI. |
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,2 @@ | ||
Advanced | ||
-------- |
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,34 @@ | ||
""" | ||
======================== | ||
Colormaps and colorbars | ||
======================== | ||
Set colormaps and show colorbars. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
|
||
fig, ax = plt.subplots(figsize=(6, 2.5)) | ||
|
||
ax, collections = xgi.draw( | ||
H, | ||
pos=pos, | ||
node_fc=H.nodes.degree, | ||
edge_fc=H.edges.size, | ||
edge_fc_cmap="viridis", | ||
node_fc_cmap="mako_r", | ||
) | ||
|
||
node_col, _, edge_col = collections | ||
|
||
plt.colorbar(node_col, label="Node degree") | ||
plt.colorbar(edge_col, label="Edge size") | ||
|
||
plt.show() |
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,19 @@ | ||
""" | ||
================= | ||
Show labels | ||
================= | ||
Draw hypergraph with labels. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
xgi.draw(H, pos=pos, node_labels=True, node_size=15, hyperedge_labels=True) | ||
|
||
plt.show() |
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,2 @@ | ||
Algorithms | ||
---------- |
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,19 @@ | ||
""" | ||
================= | ||
Simple hypergraph | ||
================= | ||
Draw simple hypergraph with manual layout. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4], [4, 5, 6, 7]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
xgi.draw(H, pos=pos) | ||
|
||
plt.show() |
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,2 @@ | ||
Basic | ||
----- |
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,19 @@ | ||
""" | ||
================= | ||
Simple hypergraph | ||
================= | ||
Draw simple hypergraph with manual layout. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
xgi.draw(H, pos=pos) | ||
|
||
plt.show() |
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,19 @@ | ||
""" | ||
=================================== | ||
Simple hypergraph with convex hulls | ||
=================================== | ||
Draw simple hypergraph with convex hulls and manual layout. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
xgi.draw(H, pos=pos, hull=True) | ||
|
||
plt.show() |
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,19 @@ | ||
""" | ||
=================================== | ||
Simple hypergraph as multilayer | ||
=================================== | ||
Draw simple hypergraph as multilayer | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
ax3 = plt.axes(projection="3d") # requires a 3d axis | ||
xgi.draw_multilayer(H, ax=ax3) | ||
|
||
plt.show() |
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,19 @@ | ||
""" | ||
=================================== | ||
Simple hypergraph with outline | ||
=================================== | ||
Draw simple hypergraph with outline and manual layout. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
xgi.draw(H, pos=pos, hull=True, edge_fc="white") | ||
|
||
plt.show() |
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,19 @@ | ||
""" | ||
========================= | ||
Simple simplicial complex | ||
========================= | ||
Draw simple simplicial complex with manual layout. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.SimplicialComplex(hyperedges) | ||
|
||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
xgi.draw(H, pos=pos) | ||
|
||
plt.show() |
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,2 @@ | ||
Layouts | ||
------- |
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,19 @@ | ||
""" | ||
================= | ||
Barycenter spring | ||
================= | ||
Draw simple hypergraph with barycenter_spring layout. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
xgi.draw(H, pos=pos) | ||
|
||
plt.show() |
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,19 @@ | ||
""" | ||
================= | ||
Circular | ||
================= | ||
Draw simple hypergraph with circular layout. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.circular_layout(H) | ||
xgi.draw(H, pos=pos) | ||
|
||
plt.show() |
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,19 @@ | ||
""" | ||
================= | ||
Spiral | ||
================= | ||
Draw simple hypergraph with spiral layout. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
|
||
pos = xgi.spiral_layout(H) | ||
xgi.draw(H, pos=pos) | ||
|
||
plt.show() |
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,2 @@ | ||
Stats | ||
----- |
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,28 @@ | ||
""" | ||
=================== | ||
Color based on stat | ||
=================== | ||
Set node colors based on stat | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import xgi | ||
|
||
hyperedges = [[1, 2, 3], [3, 4, 5], [3, 6], [6, 7, 8, 9], [1, 4, 10, 11, 12], [1, 4]] | ||
H = xgi.Hypergraph(hyperedges) | ||
|
||
pos = xgi.barycenter_spring_layout(H, seed=1) | ||
|
||
ax, collections = xgi.draw( | ||
H, | ||
pos=pos, | ||
node_fc=H.nodes.degree, | ||
edge_fc="grey", | ||
node_fc_cmap="mako_r", | ||
) | ||
|
||
node_col, _, edge_col = collections | ||
|
||
plt.colorbar(node_col, label="Node degree") | ||
plt.show() |