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
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
#[derive(Debug, PartialEq)]
pub struct Graph {
  pub strict: bool,
  pub graph_type: Option<GraphType>,
  pub id: Option<String>,
  pub statements: Vec<Statement>,
}

#[derive(Debug, PartialEq, Clone)]
pub struct SubGraph {
  pub id: Option<String>,
  pub statements: Vec<Statement>,
}

#[derive(Debug, PartialEq)]
pub enum GraphType {
  Graph,
  Digraph,
}

#[derive(Debug, PartialEq, Clone)]
pub enum Statement {
  EdgeStatement(EdgeStatement),
  AttributeStatement(AttributeStatement),
  IdPair(IdPair),
  Subgraph(SubGraph),
  NodeStatement(NodeStatement),
}

#[derive(Debug, PartialEq, Clone)]
pub enum Edge {
  NodeId(NodeId),
  Subgraph(SubGraph),
}

#[derive(Debug, PartialEq, Clone)]
pub struct EdgeStatement {
  pub edge: Edge,
  pub edge_rhs_list: Vec<EdgeRhs>,
  pub attributes: Option<Vec<Attribute>>,
}

#[derive(Debug, PartialEq, Clone)]
pub struct EdgeRhs {
  pub edge_op: EdgeOp,
  pub edge: Edge,
}

#[derive(Debug, PartialEq, Clone)]
pub enum EdgeOp {
  Arrow,
  Line,
}

#[derive(Debug, PartialEq, Clone)]
pub struct AttributeStatement {
  pub attribute_type: AttributeType,
  pub attributes: Option<Vec<Attribute>>,
}

#[derive(Debug, PartialEq, Clone)]
pub struct NodeStatement {
  pub node_id: NodeId,
  pub attributes: Option<Vec<Attribute>>,
}

#[derive(Debug, PartialEq, Clone)]
pub enum AttributeType {
  Graph,
  Node,
  Edge,
}

#[derive(Debug, PartialEq, Clone)]
pub struct Attribute {
  pub key: String,
  pub value: String,
}

pub type IdPair = Attribute;

#[derive(Debug, PartialEq, Clone)]
pub struct NodeId {
  pub node_id: String,
  pub port: Option<Port>,
}

#[derive(Debug, PartialEq, Clone)]
pub struct Port {
  pub port_id: Option<String>,
  pub compass: Option<Compass>,
}

#[derive(Debug, PartialEq, Clone)]
pub enum Compass {
  N,
  NE,
  E,
  SE,
  S,
  SW,
  W,
  NW,
  C,
  Unknown,
}