pub struct Graph<A> {
pub strict: bool,
pub is_digraph: bool,
pub name: Option<String>,
pub stmts: StmtList<A>,
}
Expand description
This structure is an AST for the DOT graph language. The generic A
denotes the type of attributes. By default (and when parsing), it is
(&'a str, &'a str)
, i.e. two strings, one for the key and one for the
value of the attribute. The library provides functions to map from one type
to an other.
Fields§
§strict: bool
Specifies if the Graph
is strict or not. A “strict” graph must not
contain the same edge multiple times. Notice that, for undirected edge,
an edge from A
to B
and an edge from B
to A
are equals.
is_digraph: bool
Specifies if the Graph
is directed.
name: Option<String>
The name of the Graph
, if any.
stmts: StmtList<A>
The statements that describe the graph.
Implementations§
Source§impl Graph<(String, String)>
impl Graph<(String, String)>
Sourcepub fn from_file<'a, P>(p: P) -> Result<Self, GraphFromFileError<'a>>
pub fn from_file<'a, P>(p: P) -> Result<Self, GraphFromFileError<'a>>
Parses a graph from a file, which path is given. Notice that when doing so, attributes are
of type (String, String)
, not the default (&'a str, &'a str)
, since we are reading and taking
ownership of the content of the file.
Source§impl<A> Graph<A>
impl<A> Graph<A>
Sourcepub fn filter_map<B>(self, f: &dyn Fn(A) -> Option<B>) -> Graph<B>
pub fn filter_map<B>(self, f: &dyn Fn(A) -> Option<B>) -> Graph<B>
Filter and map attributes. The main intended usage of this function is
to convert attributes as &'a str
into an enum, e.g.
to convert ["label"="whatever", "color"="foo"]
into
[Attr::Label(whatever), Attr::Color(foo)]
.
To take into account non-standard attributes, the Attr
enum has to be
provided by the user.
Sourcepub fn get_node_ids(self) -> HashSet<NodeID>
pub fn get_node_ids(self) -> HashSet<NodeID>
Returns all NodeID
s that appear in the graph.
Trait Implementations§
Source§impl<A: Ord> Ord for Graph<A>
impl<A: Ord> Ord for Graph<A>
Source§impl<A: PartialOrd> PartialOrd for Graph<A>
impl<A: PartialOrd> PartialOrd for Graph<A>
Source§impl<'a, A> TryFrom<Pair<'a, Rule>> for Graph<A>
impl<'a, A> TryFrom<Pair<'a, Rule>> for Graph<A>
Source§type Error = ParseError<'a>
type Error = ParseError<'a>
impl<A: Eq> Eq for Graph<A>
impl<A> StructuralPartialEq for Graph<A>
Auto Trait Implementations§
impl<A> Freeze for Graph<A>
impl<A> RefUnwindSafe for Graph<A>where
A: RefUnwindSafe,
impl<A> Send for Graph<A>where
A: Send,
impl<A> Sync for Graph<A>where
A: Sync,
impl<A> Unpin for Graph<A>where
A: Unpin,
impl<A> UnwindSafe for Graph<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more