Struct graphlang::GraphGrammar
source · [−]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
sourceimpl<NL: Label, EL: Label> GraphGrammar<u32, NL, EL>
impl<NL: Label, EL: Label> GraphGrammar<u32, NL, EL>
sourceimpl<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
sourceimpl<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>
sourcefn clone(&self) -> GraphGrammar<I, NL, EL>
fn clone(&self) -> GraphGrammar<I, NL, EL>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<I: Debug + Index, NL: Debug + Label, EL: Debug + Label> Debug for GraphGrammar<I, NL, EL>
impl<I: Debug + Index, NL: Debug + Label, EL: Debug + Label> Debug for GraphGrammar<I, NL, EL>
sourceimpl<'de, I: Index, NL: Label, EL: Label> Deserialize<'de> for GraphGrammar<I, NL, EL> where
I: Deserialize<'de>,
NL: Deserialize<'de>,
EL: Deserialize<'de>,
impl<'de, I: Index, NL: Label, EL: Label> Deserialize<'de> for GraphGrammar<I, NL, EL> where
I: Deserialize<'de>,
NL: Deserialize<'de>,
EL: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<I: Index> From<&'_ GraphGrammar<I, &'_ str, ()>> for GraphGrammar<I, String, ()>
impl<I: Index> From<&'_ GraphGrammar<I, &'_ str, ()>> for GraphGrammar<I, String, ()>
sourcefn from(gg: &GraphGrammar<I, &str, ()>) -> Self
fn from(gg: &GraphGrammar<I, &str, ()>) -> Self
Converts to this type from the input type.
sourceimpl<I: Index> From<GraphGrammar<I, &'_ str, ()>> for GraphGrammar<I, String, ()>
impl<I: Index> From<GraphGrammar<I, &'_ str, ()>> for GraphGrammar<I, String, ()>
sourcefn from(gg: GraphGrammar<I, &str, ()>) -> Self
fn from(gg: GraphGrammar<I, &str, ()>) -> Self
Converts to this type from the input type.
sourceimpl<I: PartialEq + Index, NL: PartialEq + Label, EL: PartialEq + Label> PartialEq<GraphGrammar<I, NL, EL>> for GraphGrammar<I, NL, EL>
impl<I: PartialEq + Index, NL: PartialEq + Label, EL: PartialEq + Label> PartialEq<GraphGrammar<I, NL, EL>> for GraphGrammar<I, NL, EL>
sourcefn eq(&self, other: &GraphGrammar<I, NL, EL>) -> bool
fn eq(&self, other: &GraphGrammar<I, NL, EL>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &GraphGrammar<I, NL, EL>) -> bool
fn ne(&self, other: &GraphGrammar<I, NL, EL>) -> bool
This method tests for !=
.
sourceimpl<I: Index, NL: Label, EL: Label> Serialize for GraphGrammar<I, NL, EL> where
I: Serialize,
NL: Serialize,
EL: Serialize,
impl<I: Index, NL: Label, EL: Label> Serialize for GraphGrammar<I, NL, EL> where
I: Serialize,
NL: Serialize,
EL: Serialize,
impl<I: Index, NL: Label, EL: Label> StructuralPartialEq for GraphGrammar<I, NL, EL>
Auto Trait Implementations
impl<I, NL, EL> RefUnwindSafe for GraphGrammar<I, NL, EL> where
EL: RefUnwindSafe,
I: RefUnwindSafe,
NL: RefUnwindSafe,
impl<I, NL, EL> Send for GraphGrammar<I, NL, EL> where
EL: Send,
I: Send,
NL: Send,
impl<I, NL, EL> Sync for GraphGrammar<I, NL, EL> where
EL: Sync,
I: Sync,
NL: Sync,
impl<I, NL, EL> Unpin for GraphGrammar<I, NL, EL> where
EL: Unpin,
I: Unpin,
NL: Unpin,
impl<I, NL, EL> UnwindSafe for GraphGrammar<I, NL, EL> where
EL: UnwindSafe,
I: UnwindSafe,
NL: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more