-
Notifications
You must be signed in to change notification settings - Fork 24
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
Ability to select arbitrary source and sink #115
Comments
I would like to know how does this affects the parallelization procces, I think it actually standardize the process and makes it easier |
Thanks! @andrea-cassioli-maersk |
@tomatoes-prog I guess I am missing some points, but how would you run in parallel searches from a number of source/target pairs? |
import multiprocessing as mp
import networkx as nx
def run(input_data):
G, source, sink = input_data
G = nx.relabel_nodes(G, {source: "Source", sink: "Sink"}, copy=False)
print(f"In run, mapping {source}->'Source', {sink} -> 'Sink'. Edges: {G.edges()}")
if __name__ == "__main__":
G = nx.DiGraph()
G.add_edge(0, 1)
G.add_edge(2, 3)
with mp.Pool() as pool:
pool.map(run, [(G, 0, 1), (G, 2, 3)])
print(f"Done: {G.edges()}") Expected output:
|
But you are not copying the graph, so each process will try to modify the source/sink, will it not? |
OK, I need to look a bit more into Given that the graph get copied, there is no issue, but still |
Is your feature request related to a problem? Please describe.
I am always frustrated that I have to rename source and sink in order to fit
cspy
format. Moreover, it makes difficult to parallelise its execution.Describe the solution you'd like
I would like to have two optional parameters to set an alternative name for the source and/or sink
Describe alternatives you've considered
NA
The text was updated successfully, but these errors were encountered: