easygraph.functions.drawing package
Submodules
easygraph.functions.drawing.defaults module
- easygraph.functions.drawing.defaults.default_bipartite_size(num_u: int, num_v: int, e_list: List[tuple], u_size: float | list = 1.0, u_line_width: float | list = 1.0, v_size: float | list = 1.0, v_line_width: float | list = 1.0, e_line_width: float | list = 1.0, u_font_size: float = 1.0, v_font_size: float = 1.0)[source]
- easygraph.functions.drawing.defaults.default_bipartite_strength(num_u: int, num_v: int, e_list: List[tuple], push_u_strength: float = 1.0, push_v_strength: float = 1.0, push_e_strength: float = 1.0, pull_e_strength: float = 1.0, pull_u_center_strength: float = 1.0, pull_v_center_strength: float = 1.0)[source]
- easygraph.functions.drawing.defaults.default_bipartite_style(num_u: int, num_v: int, num_e: int, u_color: str | list = 'm', v_color: str | list = 'r', e_color: str | list = 'gray', e_fill_color: str | list = 'whitesmoke')[source]
- easygraph.functions.drawing.defaults.default_hypergraph_strength(num_v: int, e_list: List[tuple], 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]
- easygraph.functions.drawing.defaults.default_hypergraph_style(num_v: int, num_e: int, v_color: str | list = 'r', e_color: str | list = 'gray', e_fill_color: str | list = 'whitesmoke')[source]
- easygraph.functions.drawing.defaults.default_size(num_v: int, e_list: List[tuple], v_size: float | list = 1.0, v_line_width: float | list = 1.0, e_line_width: float | list = 1.0, font_size: float = 1.0)[source]
- easygraph.functions.drawing.defaults.default_strength(num_v: int, e_list: List[tuple], 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]
- easygraph.functions.drawing.defaults.default_style(num_v: int, num_e: int, v_color: str | list = 'r', e_color: str | list = 'gray', e_fill_color: str | list = 'whitesmoke')[source]
- easygraph.functions.drawing.defaults.fill_color(custom_color: str | list | None, default_color: Any, length: int)[source]
easygraph.functions.drawing.drawing module
- easygraph.functions.drawing.drawing.draw_SHS_center(G, SHS, rate=1, style='side')[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='side')[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_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
easygraph.functions.drawing.geometry module
easygraph.functions.drawing.layout module
easygraph.functions.drawing.plot module
- easygraph.functions.drawing.plot.plot_Betweenness_Centrality(G, SHS)[source]
Returns the CDF curves of “Betweenness Centralitys” of SH spanners and ordinary users in graph G.
- Parameters:
G (graph) – A easygraph graph.
SHS (list) – The SH Spanners in graph G.
- Returns:
plt – the CDF curves of “Betweenness Centrality” of SH spanners and ordinary users in graph G.
- Return type:
CDF curves
- easygraph.functions.drawing.plot.plot_Connected_Communities(G, SHS)[source]
Returns the CDF curves of “Number of Connected Communities” of SH spanners and ordinary users in graph G.
- Parameters:
G (graph) – A easygraph graph.
SHS (list) – The SH Spanners in graph G.
- Returns:
plt – the CDF curves of “Number of Connected Communities” of SH spanners and ordinary users in graph G.
- Return type:
CDF curves
- easygraph.functions.drawing.plot.plot_Followers(G, SHS)[source]
Returns the CDF curves of “Number of Followers” of SH spanners and ordinary users in graph G.
- Parameters:
G (graph) – A easygraph graph.
SHS (list) – The SH Spanners in graph G.
- Returns:
plt – the CDF curves of “Number of Followers” of SH spanners and ordinary users in graph G.
- Return type:
CDF curves
- easygraph.functions.drawing.plot.plot_Neighborhood_Followers(G, SHS)[source]
Returns the CDF curves of “Arg. Number of Followers of the Neighborhood Users” of SH spanners and ordinary users in graph G.
- Parameters:
G (graph) – A easygraph graph.
SHS (list) – The SH Spanners in graph G.
- Returns:
plt – the CDF curves of “Arg. Number of Followers of the Neighborhood Users ” of SH spanners and ordinary users in graph G.
- Return type:
CDF curves
easygraph.functions.drawing.positioning module
- easygraph.functions.drawing.positioning.circular_position(G, center=None, scale=1)[source]
Position nodes on a circle, the dimension is 2.
- Parameters:
G (easygraph.Graph or easygraph.DiGraph) – A position will be assigned to every node in G
center (array-like or None, optional (default : None)) – Coordinate pair around which to center the layout
scale (number, optional (default : 1)) – Scale factor for positions
- Returns:
pos – A dictionary of positions keyed by node
- Return type:
dict
- easygraph.functions.drawing.positioning.kamada_kawai_layout(G, dist=None, pos=None, weight='weight', scale=1, center=None, dim=2)[source]
Position nodes using Kamada-Kawai basic-length cost-function.
- Parameters:
G (graph or list of nodes) – A position will be assigned to every node in G.
dist (dict (default=None)) – A two-level dictionary of optimal distances between nodes, indexed by source and destination node. If None, the distance is computed using shortest_path_length().
pos (dict or None optional (default=None)) – Initial positions for nodes as a dictionary with node as keys and values as a coordinate list or tuple. If None, then use circular_layout() for dim >= 2 and a linear layout for dim == 1.
weight (string or None optional (default='weight')) – The edge attribute that holds the numerical value used for the edge weight. If None, then all edge weights are 1.
scale (number (default: 1)) – Scale factor for positions.
center (array-like or None) – Coordinate pair around which to center the layout.
dim (int) – Dimension of layout.
- Returns:
pos – A dictionary of positions keyed by node
- Return type:
dict
Examples
>>> pos = eg.kamada_kawai_layout(G)
- easygraph.functions.drawing.positioning.random_position(G, center=None, dim=2, random_seed=None)[source]
Returns random position for each node in graph G.
- Parameters:
G (easygraph.Graph or easygraph.DiGraph) –
center (array-like or None, optional (default : None)) – Coordinate pair around which to center the layout
dim (int, optional (default : 2)) – Dimension of layout
random_seed (int or None, optional (default : None)) – Seed for RandomState instance
- Returns:
pos – A dictionary of positions keyed by node
- Return type:
dict
- easygraph.functions.drawing.positioning.rescale_position(pos, scale=1)[source]
Returns scaled position array to (-scale, scale) in all axes.
- Parameters:
pos (numpy array) – positions to be scaled. Each row is a position.
scale (number, optional (default : 1)) – The size of the resulting extent in all directions.
- Returns:
pos – scaled positions. Each row is a position.
- Return type:
numpy array
- easygraph.functions.drawing.positioning.shell_position(G, nlist=None, scale=1, center=None)[source]
Position nodes in concentric circles, the dimension is 2.
- Parameters:
G (easygraph.Graph or easygraph.DiGraph) –
nlist (list of lists or None, optional (default : None)) – List of node lists for each shell.
scale (number, optional (default : 1)) – Scale factor for positions.
center (array-like or None, optional (default : None)) – Coordinate pair around which to center the layout.
- Returns:
pos – A dictionary of positions keyed by node
- Return type:
dict
Notes
This algorithm currently only works in two dimensions and does not try to minimize edge crossings.
easygraph.functions.drawing.simulator module
easygraph.functions.drawing.utils module
- easygraph.functions.drawing.utils.draw_circle_edge(ax: Axes, v_coor: List[Tuple[float, float]], v_size: list, e_list: List[Tuple[int, int]], e_color: list, e_fill_color: list, e_line_width: list)[source]
- easygraph.functions.drawing.utils.draw_line_edge(ax: Axes, v_coor: array, v_size: list, e_list: List[Tuple[int, int]], show_arrow: bool, e_color: list, e_line_width: list)[source]
- easygraph.functions.drawing.utils.draw_vertex(ax: Axes, v_coor: List[Tuple[float, float]], v_label: List[str] | None, font_size: int, font_family: str, v_size: list, v_color: list, v_line_width: list)[source]
- easygraph.functions.drawing.utils.edge_list_to_incidence_matrix(num_v: int, e_list: List[tuple]) ndarray [source]
- easygraph.functions.drawing.utils.hull_layout(n_v, e_list, pos, v_size, radius_increment=0.3)[source]