Skip to content

Commit

Permalink
Increase space around graph labels
Browse files Browse the repository at this point in the history
Ref. #345
  • Loading branch information
Alexander Senier authored and treiher committed Jul 29, 2020
1 parent 2fe54a4 commit 2232dd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion rflx/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def get(self) -> Dot:
for f in self.__message.fields:
result.add_node(Node(name=f.name))
for l in self.__message.structure:
result.add_edge(Edge(src=l.source.name, dst=l.target.name, xlabel=self.__edge_label(l)))
label = self.__edge_label(l).replace("\n", " \n ")
result.add_edge(Edge(src=l.source.name, dst=l.target.name, xlabel=f" {label} "))
result.add_node(
Node(name="Final", fillcolor="#6f6f6f", shape="circle", width="0.5", label="")
)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_empty_message_graph() -> None:
node [color="#6f6f6f", fillcolor="#009641", fontcolor="#ffffff", fontname=Arimo,
shape=box, style="rounded,filled", width="1.5"];
Initial [fillcolor="#ffffff", label="", shape=circle, width="0.5"];
Initial -> Final [xlabel="(⊤, 0, ⋆)"];
Initial -> Final [xlabel=" (⊤, 0, ⋆) "];
Final [fillcolor="#6f6f6f", label="", shape=circle, width="0.5"];
}
"""
Expand All @@ -69,8 +69,8 @@ def test_dot_graph() -> None:
shape=box, style="rounded,filled", width="1.5"];
Initial [fillcolor="#ffffff", label="", shape=circle, width="0.5"];
X;
Initial -> X [xlabel="(⊤, 32, ⋆)"];
X -> Final [xlabel="(⊤, 0, ⋆)"];
Initial -> X [xlabel=" (⊤, 32, ⋆) "];
X -> Final [xlabel=" (⊤, 0, ⋆) "];
Final [fillcolor="#6f6f6f", label="", shape=circle, width="0.5"];
}
"""
Expand All @@ -96,8 +96,8 @@ def test_dot_graph_with_condition() -> None:
shape=box, style="rounded,filled", width="1.5"];
Initial [fillcolor="#ffffff", label="", shape=circle, width="0.5"];
X;
Initial -> X [xlabel="(⊤, 32, ⋆)"];
X -> Final [xlabel="(X > 100, 0, ⋆)"];
Initial -> X [xlabel=" (⊤, 32, ⋆) "];
X -> Final [xlabel=" (X > 100, 0, ⋆) "];
Final [fillcolor="#6f6f6f", label="", shape=circle, width="0.5"];
}
"""
Expand All @@ -124,9 +124,9 @@ def test_dot_graph_with_double_edge() -> None:
shape=box, style="rounded,filled", width="1.5"];
Initial [fillcolor="#ffffff", label="", shape=circle, width="0.5"];
X;
Initial -> X [xlabel="(⊤, 32, ⋆)"];
X -> Final [xlabel="(X > 100, 0, ⋆)"];
X -> Final [xlabel="(X < 50, 0, ⋆)"];
Initial -> X [xlabel=" (⊤, 32, ⋆) "];
X -> Final [xlabel=" (X > 100, 0, ⋆) "];
X -> Final [xlabel=" (X < 50, 0, ⋆) "];
Final [fillcolor="#6f6f6f", label="", shape=circle, width="0.5"];
}
"""
Expand Down

0 comments on commit 2232dd3

Please sign in to comment.