-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graph instance modified in place by scale_free_graph
#4729
Comments
The standard treatment is that So... That argument -- |
Yes, this is the first instance that I've come across where this wasn't the case. In this particular case, I think this may just be the result of imprecise argument naming. I think the intended behavior would be better reflected by a better argument name, e.g. if initial_graph is not None:
G = initial_graph.copy()
else:
G = nx.MultiDiGraph([(0, 1), (1, 2), (2, 0)]) # This is the default initialization for the current implementation |
The feature of having a graph to start building a new graph also appears in #4659 and we should probably be consistent in our choice of names. Should the argument be named |
I think both names are good and equally clear. I have a slight preference for |
nx.scale_free_graph
has acreate_using
argument which accepts different types of inputs. When a graph instance is provided, it is used as a starting point for the graph to which more nodes will be added as is clearly described in the docstring.However, the instance passed in via
create_using
is also modified in place:This behavior should either be documented, or the
create_using
argument should be copied (when a graph instance) to prevent the in-place modification. I think the second option is more consistent with the other functions in NetworkX, which generally try to avoid in-place modification of inputs.The text was updated successfully, but these errors were encountered: