summaryrefslogtreecommitdiff
path: root/src/attributes/output_mode.rs
blob: 5a6ab45e55210165b100ba1c661a4360f1b2f9d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::dot::DotString;
use std::borrow::Cow;

/// These specify the order in which nodes and edges are drawn in concrete output.
///
/// The default "breadthfirst" is the simplest, but when the graph layout does not avoid edge-node
/// overlap, this mode will sometimes have edges drawn over nodes and sometimes on top of nodes.
///
/// If the mode "nodesfirst" is chosen, all nodes are drawn first, followed by the edges.
/// This guarantees an edge-node overlap will not be mistaken for an edge ending at a node.
///
/// On the other hand, usually for aesthetic reasons, it may be desirable that all edges appear
/// beneath nodes, even if the resulting drawing is ambiguous.
/// This can be achieved by choosing "edgesfirst".
pub enum OutputMode {
    BreadthFirst,
    NodesFirst,
    EdgesFirst,
}

impl<'a> DotString<'a> for OutputMode {
    fn dot_string(&self) -> Cow<'a, str> {
        match self {
            OutputMode::BreadthFirst => "breadthfirst".into(),
            OutputMode::NodesFirst => "nodesfirst".into(),
            OutputMode::EdgesFirst => "edgesfirst".into(),
        }
    }
}