Stack
net-bench enables fast processing of multiple ImageGenerators
with ImageCollection. In an ImageCollection object, multiple ImageGenerator objects
can be added in a similar way as to a list. This allows for several usages:
Creating a Flipbook
A flipbook in the form of a PDF or a Powerpoint can be created with an
ImageCollection object. First some preparation to get a simple graph:
import pathlib
import dsslab.net_bench as dnb
import networkx as nx
graph = nx.DiGraph()
graph.add_nodes_from([1, 2, 3, 4, 5])
graph.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 5)])
pathlib allows for the easy usage of paths to directories and files.
We create an ImageGenerator and set positions, which we choose ourselves:
image_generator = ImageGenerator(graph)
positions = {
1: [-0.64773329, -0.61381879],
2: [-0.08689388, -0.64267512],
3: [0.11388331, -0.15139483],
4: [0.13119441, 0.40788873],
5: [0.48954945, 1.0],
}
image_generator.nodes.set_positions(positions)
We create an ImageCollection with a ImageGenerator and add a second ImageGenerator.
Now we can draw using the object image_stack, in this case a powerpoint presentation:
To draw a PDF with all ImageGenerators, we would have to do this:
Note
Look at the different file endings! When working with net-bench, this is how you
recognize if you want to export as a PDF or as a PPTX.