rustworkx.generators.directed_star_graph¶
- directed_star_graph(num_nodes=None, weights=None, inward=False, bidirectional=False, multigraph=True, /)¶
Generate a directed star graph
- Parameters:
num_node (int) – The number of nodes to generate the graph with. Node weights will be None if this is specified. If both
num_nodeandweightsare set this will be ignored andweightswill be used.weights (list) – A list of node weights, the first element in the list will be the center node of the star graph. If both
num_nodeandweightsare set this will be ignored andweightswill be used.bidirectional (bool) – Adds edges in both directions between two nodes if set to
True. Default value isFalse.inward (bool) – If set
Truethe nodes will be directed towards the center node. This parameter is ignored ifbidirectionalis set toTrue.multigraph (bool) – When set to False the output
PyDiGraphobject will not be not be a multigraph and won’t allow parallel edges to be added. Instead calls which would create a parallel edge will update the existing edge.
- Returns:
The generated star graph
- Return type:
- Raises:
IndexError – If neither
num_nodesorweightsare specified
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.directed_star_graph(10) mpl_draw(graph)
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.directed_star_graph(10, inward=True) mpl_draw(graph)