Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.classes.function.add_star

add_star(G, nodes, **attr)[source]

Add a star to Graph G.

The first node in nodes is the middle of the star. It is connected to all other nodes.

Parameters:
  • nodes (iterable container) – A container of nodes.
  • attr (keyword arguments, optional (default= no attributes)) – Attributes to add to every edge in star.

Examples

>>> G = nx.Graph()
>>> nx.add_star(G, [0, 1, 2, 3])
>>> nx.add_star(G, [10, 11, 12], weight=2)