Skip to content
Snippets Groups Projects
Commit cc9d6f0a authored by markn92's avatar markn92
Browse files

Add possibility to create all graphs as tex files.

parent c993ce97
No related branches found
No related tags found
No related merge requests found
.idea
plots
__pycache__
# Routing for Electric Vehicles
## Extras
### Draw Graphs used for Testing
To draw all graphs, respectively create ```.tex``` snippets (that make use of the
[tikz-network](https://www.ctan.org/pkg/tikz-network)).
```bash
python draw_graphs.py [export_dir_path]
```
......@@ -50,3 +50,26 @@ def _get_node_styles(G):
styles['nodes_style'] = nodes_style
return styles
if __name__ == '__main__':
# Write Latex files of all test case graph configs
import os
import sys
from tests import config
try:
plot_dir = sys.argv[1]
except IndexError:
plot_dir = 'plots'
if config.config_list:
try:
os.mkdir(plot_dir)
except FileExistsError:
pass
for conf_name in config.config_list:
conf = getattr(config, conf_name)
G = config.get_graph(conf)
draw_graph(G, os.path.join(plot_dir, conf_name + '.tex'))
......@@ -5,6 +5,9 @@ import networkx as nx
Street = namedtuple('Street', ['u', 'v', 'distance', 'consumption'])
Node = namedtuple('Node', ['label', 'charging_coeff'], defaults=(None, None))
# List of configs
config_list = ['edge_case']
edge_case = {
'b_0': 0,
'b_t': 0,
......
import networkx as nx
from .draw import draw_graph
def test_graph_creation(G_Edge_Case: nx.Graph):
assert G_Edge_Case.number_of_nodes() == 3
assert G_Edge_Case.number_of_edges() == 3
def test_print_graph(G_Edge_Case: nx.Graph):
draw_graph(G_Edge_Case, 'graph.tex')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment