easygraph.functions.drawing.drawing module#
- easygraph.functions.drawing.drawing.draw_SHS_center(G, SHS, rate=1, style='center')[source]#
Draw the graph whose the SH Spanners are in the center, with random layout.
- Parameters:
G (graph) – A easygraph graph.
SHS (list) – The SH Spanners in graph G.
rate (float) – The proportion of visible points and edges to the total
style (string) – “side”- the label is next to the dot “center”- the label is in the center of the dot
- Returns:
graph – the graph whose the SH Spanners are in the center.
- Return type:
network
- easygraph.functions.drawing.drawing.draw_SHS_center_kk(G, SHS, rate=1, style='center')[source]#
Draw the graph whose the SH Spanners are in the center, with a Kamada-Kawai force-directed layout.
- Parameters:
G (graph) – A easygraph graph.
SHS (list) – The SH Spanners in graph G.
rate (float) – The proportion of visible points and edges to the total
style (string) – “side”- the label is next to the dot “center”- the label is in the center of the dot
- Returns:
graph – the graph whose the SH Spanners are in the center.
- Return type:
network
- easygraph.functions.drawing.drawing.draw_dynamic_hypergraph(G, group_name_list=None, column_size=None, save_path=None, title_font_size=4, e_style: str = 'circle', v_label: List[str] | None = None, v_size: float | list = 2.0, v_color: str | list = 'r', v_line_width: str | list = 1.0, e_color: str | list = 'gray', e_fill_color: str | list = 'whitesmoke', e_line_width: str | list = 1.0, font_size: float = 1.0, font_family: str = 'sans-serif', push_v_strength: float = 1.0, push_e_strength: float = 1.0, pull_e_strength: float = 1.0, pull_center_strength: float = 1.0)[source]#
- Parameters:
eg.Hypergraph (G) –
visualize (group_name_list The groups to) –
row (column_size The number of subplots placed in each) –
visualization (save_path path to save) –
subplot (title_font_size The font size of tilte of each) –
- easygraph.functions.drawing.drawing.draw_easygraph_edges(G, pos, edgelist=None, width=1.0, edge_color='k', style='solid', alpha=None, arrowstyle=None, arrowsize=10, edge_cmap=None, edge_vmin=None, edge_vmax=None, ax=None, arrows=None, label=None, node_size=300, nodelist=None, node_shape='o', connectionstyle='arc3', min_source_margin=0, min_target_margin=0)[source]#
Draw the edges of the graph G.
This draws only the edges of the graph G.
- Parameters:
G (graph) – A easygraph graph
pos (dictionary) – A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.
edgelist (collection of edge tuples (default=G.edges())) – Draw only specified edges
width (float or array of floats (default=1.0)) – Line width of edges
edge_color (color or array of colors (default='k')) – Edge color. Can be a single color or a sequence of colors with the same length as edgelist. Color can be string or rgb (or rgba) tuple of floats from 0-1. If numeric values are specified they will be mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.
style (string or array of strings (default='solid')) – Edge line style e.g.: ‘-’, ‘–’, ‘-.’, ‘:’ or words like ‘solid’ or ‘dashed’. Can be a single style or a sequence of styles with the same length as the edge list. If less styles than edges are given the styles will cycle. If more styles than edges are given the styles will be used sequentially and not be exhausted. Also, (offset, onoffseq) tuples can be used as style instead of a strings. (See matplotlib.patches.FancyArrowPatch: linestyle)
alpha (float or array of floats (default=None)) – The edge transparency. This can be a single alpha value, in which case it will be applied to all specified edges. Otherwise, if it is an array, the elements of alpha will be applied to the colors in order (cycling through alpha multiple times if necessary).
edge_cmap (Matplotlib colormap, optional) – Colormap for mapping intensities of edges
edge_vmin (floats, optional) – Minimum and maximum for edge colormap scaling
edge_vmax (floats, optional) – Minimum and maximum for edge colormap scaling
ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.
arrows (bool or None, optional (default=None)) –
If None, directed graphs draw arrowheads with ~matplotlib.patches.FancyArrowPatch, while undirected graphs draw edges via ~matplotlib.collections.LineCollection for speed. If True, draw arrowheads with FancyArrowPatches (bendable and stylish). If False, draw edges using LineCollection (linear and fast).
Note: Arrowheads will be the same color as edges.
arrowstyle (str (default='-|>' for directed graphs)) –
For directed graphs and arrows==True defaults to ‘-|>’, For undirected graphs default to ‘-‘.
See matplotlib.patches.ArrowStyle for more options.
arrowsize (int (default=10)) – For directed graphs, choose the size of the arrow head’s length and width. See matplotlib.patches.FancyArrowPatch for attribute mutation_scale for more info.
connectionstyle (string (default="arc3")) – Pass the connectionstyle parameter to create curved arc of rounding radius rad. For example, connectionstyle=’arc3,rad=0.2’. See matplotlib.patches.ConnectionStyle and matplotlib.patches.FancyArrowPatch for more info.
node_size (scalar or array (default=300)) – Size of nodes. Though the nodes are not drawn with this function, the node size is used in determining edge positioning.
nodelist (list, optional (default=G.nodes())) – This provides the node order for the node_size array (if it is an array).
node_shape (string (default='o')) – The marker used for nodes, used in determining edge positioning. Specification is as a matplotlib.markers marker, e.g. one of ‘so^>v<dph8’.
label (None or string) – Label for legend
min_source_margin (int (default=0)) – The minimum margin (gap) at the beginning of the edge at the source.
min_target_margin (int (default=0)) – The minimum margin (gap) at the end of the edge at the target.
- Returns:
If
arrows=True
, a list of FancyArrowPatches is returned. Ifarrows=False
, a LineCollection is returned. Ifarrows=None
(the default), then a LineCollection is returned if G is undirected, otherwise returns a list of FancyArrowPatches.- Return type:
matplotlib.collections.LineCollection or a list of matplotlib.patches.FancyArrowPatch
Notes
For directed graphs, arrows are drawn at the head end. Arrows can be turned off with keyword arrows=False or by passing an arrowstyle without an arrow on the end.
Be sure to include node_size as a keyword argument; arrows are drawn considering the size of nodes.
Self-loops are always drawn with ~matplotlib.patches.FancyArrowPatch regardless of the value of arrows or whether G is directed. When
arrows=False
orarrows=None
and G is undirected, the FancyArrowPatches corresponding to the self-loops are not explicitly returned. They should instead be accessed via theAxes.patches
attribute (see examples).
- easygraph.functions.drawing.drawing.draw_easygraph_nodes(G, pos, nodelist=None, node_size=300, node_color='#1f78b4', node_shape='o', alpha=None, cmap=None, vmin=None, vmax=None, ax=None, linewidths=None, edgecolors=None, label=None, margins=None)[source]#
Draw the nodes of the graph G.
This draws only the nodes of the graph G.
- Parameters:
G (graph) – A EasyGraph graph
pos (dictionary) – A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.
ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.
nodelist (list (default list(G))) – Draw only specified nodes
node_size (scalar or array (default=300)) – Size of nodes. If an array it must be the same length as nodelist.
node_color (color or array of colors (default='#1f78b4')) – Node color. Can be a single color or a sequence of colors with the same length as nodelist. Color can be string or rgb (or rgba) tuple of floats from 0-1. If numeric values are specified they will be mapped to colors using the cmap and vmin,vmax parameters. See matplotlib.scatter for more details.
node_shape (string (default='o')) – The shape of the node. Specification is as matplotlib.scatter marker, one of ‘so^>v<dph8’.
alpha (float or array of floats (default=None)) – The node transparency. This can be a single alpha value, in which case it will be applied to all the nodes of color. Otherwise, if it is an array, the elements of alpha will be applied to the colors in order (cycling through alpha multiple times if necessary).
cmap (Matplotlib colormap (default=None)) – Colormap for mapping intensities of nodes
vmin (floats or None (default=None)) – Minimum and maximum for node colormap scaling
vmax (floats or None (default=None)) – Minimum and maximum for node colormap scaling
linewidths ([None | scalar | sequence] (default=1.0)) – Line width of symbol border
edgecolors ([None | scalar | sequence] (default = node_color)) – Colors of node borders. Can be a single color or a sequence of colors with the same length as nodelist. Color can be string or rgb (or rgba) tuple of floats from 0-1. If numeric values are specified they will be mapped to colors using the cmap and vmin,vmax parameters. See ~matplotlib.pyplot.scatter for more details.
label ([None | string]) – Label for legend
margins (float or 2-tuple, optional) – Sets the padding for axis autoscaling. Increase margin to prevent clipping for nodes that are near the edges of an image. Values should be in the range
[0, 1]
. Seematplotlib.axes.Axes.margins()
for details. The default is None, which uses the Matplotlib default.
- Returns:
PathCollection of the nodes.
- Return type:
matplotlib.collections.PathCollection
Examples
>>> G = eg.dodecahedral_graph() >>> nodes = eg.draw_easygraph_nodes(G, pos=eg.spring_layout(G))
- easygraph.functions.drawing.drawing.draw_gm_com(G, gm_com)[source]#
Draw the graph and show the communities
- Parameters:
G (graph) –
gm_com (communities created by greedy modularity) –
- easygraph.functions.drawing.drawing.draw_hypergraph(hg: Hypergraph, e_style: str = 'circle', v_label: List[str] | None = None, v_size: float | list = 1.0, v_color: str | list = 'r', v_line_width: str | list = 1.0, e_color: str | list = 'gray', e_fill_color: str | list = 'whitesmoke', e_line_width: str | list = 1.0, font_size: float = 1.0, font_family: str = 'sans-serif', push_v_strength: float = 1.0, push_e_strength: float = 1.0, pull_e_strength: float = 1.0, pull_center_strength: float = 1.0)[source]#
Draw the hypergraph structure.
- Parameters:
hg (
eg.Hypergraph
) – The EasyGraph’s hypergraph object.e_style (
str
) – The style of hyperedges. The available styles are only'circle'
. Defaults to'circle'
.v_label (
list
) – The labels of vertices. Defaults toNone
.v_size (
float
orlist
) – The size of vertices. Defaults to1.0
.v_color (
str
orlist
) – The color of vertices. Defaults to'r'
.v_line_width (
float
orlist
) – The line width of vertices. Defaults to1.0
.e_color (
str
orlist
) –The color of hyperedges. Defaults to
'gray'
.e_fill_color (
str
orlist
) –The fill color of hyperedges. Defaults to
'whitesmoke'
.e_line_width (
float
orlist
) – The line width of hyperedges. Defaults to1.0
.font_size (
float
) – The font size of labels. Defaults to1.0
.font_family (
str
) – The font family of labels. Defaults to'sans-serif'
.push_v_strength (
float
) – The strength of pushing vertices. Defaults to1.0
.push_e_strength (
float
) – The strength of pushing hyperedges. Defaults to1.0
.pull_e_strength (
float
) – The strength of pulling hyperedges. Defaults to1.0
.pull_center_strength (
float
) – The strength of pulling vertices to the center. Defaults to1.0
.
- easygraph.functions.drawing.drawing.draw_kamada_kawai(G, rate=1, style='side')[source]#
Draw the graph G with a Kamada-Kawai force-directed layout.
- Parameters:
G (graph) – A easygraph graph
rate (float) – The proportion of visible points and edges to the total
style (string) – “side”- the label is next to the dot “center”- the label is in the center of the dot