You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Draw the graph with the paths and their weights highlighted.
@@ -246,21 +247,33 @@ def draw_solution_basic(
246
247
247
248
The input directed acyclic graph, as networkx DiGraph.
248
249
250
+
- `filename`: str
251
+
252
+
The name of the file to save the drawing. The file type is inferred from the extension. Supported extensions are '.bmp', '.canon', '.cgimage', '.cmap', '.cmapx', '.cmapx_np', '.dot', '.dot_json', '.eps', '.exr', '.fig', '.gd', '.gd2', '.gif', '.gtk', '.gv', '.ico', '.imap', '.imap_np', '.ismap', '.jp2', '.jpe', '.jpeg', '.jpg', '.json', '.json0', '.pct', '.pdf', '.pic', '.pict', '.plain', '.plain-ext', '.png', '.pov', '.ps', '.ps2', '.psd', '.sgi', '.svg', '.svgz', '.tga', '.tif', '.tiff', '.tk', '.vml', '.vmlz', '.vrml', '.wbmp', '.webp', '.x11', '.xdot', '.xdot1.2', '.xdot1.4', '.xdot_json', '.xlib'
253
+
249
254
- `flow_attr`: str
250
255
251
-
The attribute name from where to get the flow values on the edges.
256
+
The attribute name from where to get the flow values on the edges. Default is an empty string, in which case no edge weights are shown.
252
257
253
258
- `paths`: list
254
259
255
-
The list of paths to highlight, as lists of nodes. Default is an empty list, in which case no path is drawn.
260
+
The list of paths to highlight, as lists of nodes. Default is an empty list, in which case no path is drawn. Default is an empty list.
256
261
257
262
- `weights`: list
258
263
259
-
The list of weights corresponding to the paths. Default is an empty list, in which case no path is drawn.
264
+
The list of weights corresponding to the paths, of various colors. Default is an empty list, in which case no path is drawn.
260
265
261
-
- `id`: str
266
+
- `additional_starts`: list
267
+
268
+
A list of additional nodes to highlight in green as starting nodes. Default is an empty list.
269
+
270
+
- `additional_ends`: list
271
+
272
+
A list of additional nodes to highlight in red as ending nodes. Default is an empty list.
262
273
263
-
The identifier of the graph, to be used as filename of the file containing the drawings. Default is an empty string, in which case the object id of the graph object will be used.
274
+
- `subpath_constraints`: list
275
+
276
+
A list of subpaths to highlight in the graph as dashed edges, of various colors. Each subpath is a list of edges. Default is an empty list. There is no association between the subpath colors and the path colors.
264
277
265
278
- `draw_options`: dict
266
279
@@ -286,18 +299,8 @@ def draw_solution_basic(
286
299
287
300
The width of the path to be drawn. Default is `3.0`.
288
301
289
-
- `additional_starts`: list
290
-
291
-
A list of additional nodes to highlight in green as starting nodes. Default is an empty list.
292
-
293
-
- `additional_ends`: list
294
-
295
-
A list of additional nodes to highlight in red as ending nodes. Default is an empty list.
296
302
"""
297
303
298
-
ifid=="":
299
-
id=id(graph)
300
-
301
304
iflen(paths) !=len(weights):
302
305
raiseValueError("Paths and weights must have the same length, if provided.")
303
306
@@ -376,15 +379,27 @@ def draw_solution_basic(
376
379
dot.edge(
377
380
str(path[i]),
378
381
str(path[i+1]),
379
-
fontcolor=pathColor,
380
382
color=pathColor,
381
383
penwidth=str(draw_options.get("pathwidth", 3.0)),
382
384
)
385
+
386
+
forindex, pathinenumerate(subpath_constraints):
387
+
pathColor=colors[index%len(colors)]
388
+
foriinrange(len(path)):
389
+
iflen(path[i]) !=2:
390
+
raiseValueError("Subpaths must be lists of edges.")
0 commit comments