pub struct GraphGrammar<I: Index, NL: Label, EL: Label> {
pub start_graph: Graph<I, NL, EL>,
pub productions: HashMap<String, Production<I, NL, EL>>,
pub terminal_nodes: HashSet<NL>,
}
Expand description
A GraphGrammar
yields different graphs, that are constructible using a starting graph and a
list of transformations (productions). It is also used to further transform generated graphs
using evolve
. Refer to generate_random
.
Fields§
§start_graph: Graph<I, NL, EL>
Starting graph
productions: HashMap<String, Production<I, NL, EL>>
Number of productions, that transform a matching subgraph to another
terminal_nodes: HashSet<NL>
List of terminal nodes. A graph has to consist only of terminal nodes to be considered valid.
Implementations§
Source§impl<NL: Label, EL: Label> GraphGrammar<u32, NL, EL>
impl<NL: Label, EL: Label> GraphGrammar<u32, NL, EL>
Source§impl<I: Index, NL: Label, EL: Label> GraphGrammar<I, NL, EL>
impl<I: Index, NL: Label, EL: Label> GraphGrammar<I, NL, EL>
Sourcepub fn is_valid(&self, g: &Graph<I, NL, EL>) -> bool
pub fn is_valid(&self, g: &Graph<I, NL, EL>) -> bool
A graph has to consist only of terminal nodes to be considered valid.
This validates if a graph g
is valid under the used GraphGrammar
.
Sourcepub fn evolve(
&self,
g: &Graph<I, NL, EL>,
qc: &QuitCondition,
) -> Graph<I, NL, EL>
pub fn evolve( &self, g: &Graph<I, NL, EL>, qc: &QuitCondition, ) -> Graph<I, NL, EL>
Evolves g
by applying productions of the GraphGrammar
until the first condition
specified in qc
is statisfied and returns the resulting graph.
Sourcepub fn generate_random(
&self,
g: &Graph<I, NL, EL>,
cond: QuitCondition,
) -> Graph<I, NL, EL>
pub fn generate_random( &self, g: &Graph<I, NL, EL>, cond: QuitCondition, ) -> Graph<I, NL, EL>
Similar to evolve
. Returns the first valid graph that is part of the language
specified by the grammar using random productions on the starting graph.
§Panics
Panics if quitcondition is invalid.
Trait Implementations§
Source§impl<I: Clone + Index, NL: Clone + Label, EL: Clone + Label> Clone for GraphGrammar<I, NL, EL>
impl<I: Clone + Index, NL: Clone + Label, EL: Clone + Label> Clone for GraphGrammar<I, NL, EL>
Source§fn clone(&self) -> GraphGrammar<I, NL, EL>
fn clone(&self) -> GraphGrammar<I, NL, EL>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more