GraphGrammar

Struct 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§

Source§

impl<NL: Label, EL: Label> GraphGrammar<u32, NL, EL>

Source

pub fn evolve_single_step( &self, g: &Graph<u32, NL, EL>, ) -> Option<Graph<u32, NL, EL>>

Applies a random production, that can applied. This function is very expensive. Return None if it can’t be transformed.

Source§

impl<I: Index, NL: Label, EL: Label> GraphGrammar<I, NL, EL>

Source

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.

Source

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.

Source

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>

Source§

fn clone(&self) -> GraphGrammar<I, NL, EL>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Debug + Index, NL: Debug + Label, EL: Debug + Label> Debug for GraphGrammar<I, NL, EL>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, I, NL, EL> Deserialize<'de> for GraphGrammar<I, NL, EL>
where I: Deserialize<'de> + Index, NL: Deserialize<'de> + Label, EL: Deserialize<'de> + Label,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<I: Index> From<&GraphGrammar<I, &str, ()>> for GraphGrammar<I, String, ()>

Source§

fn from(gg: &GraphGrammar<I, &str, ()>) -> Self

Converts to this type from the input type.
Source§

impl<I: Index> From<GraphGrammar<I, &str, ()>> for GraphGrammar<I, String, ()>

Source§

fn from(gg: GraphGrammar<I, &str, ()>) -> Self

Converts to this type from the input type.
Source§

impl<I: PartialEq + Index, NL: PartialEq + Label, EL: PartialEq + Label> PartialEq for GraphGrammar<I, NL, EL>

Source§

fn eq(&self, other: &GraphGrammar<I, NL, EL>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I, NL, EL> Serialize for GraphGrammar<I, NL, EL>
where I: Serialize + Index, NL: Serialize + Label, EL: Serialize + Label,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<I: Index, NL: Label, EL: Label> StructuralPartialEq for GraphGrammar<I, NL, EL>

Auto Trait Implementations§

§

impl<I, NL, EL> Freeze for GraphGrammar<I, NL, EL>

§

impl<I, NL, EL> RefUnwindSafe for GraphGrammar<I, NL, EL>

§

impl<I, NL, EL> Send for GraphGrammar<I, NL, EL>
where I: Send, NL: Send, EL: Send,

§

impl<I, NL, EL> Sync for GraphGrammar<I, NL, EL>
where I: Sync, NL: Sync, EL: Sync,

§

impl<I, NL, EL> Unpin for GraphGrammar<I, NL, EL>
where I: Unpin, NL: Unpin, EL: Unpin,

§

impl<I, NL, EL> UnwindSafe for GraphGrammar<I, NL, EL>
where I: UnwindSafe, NL: UnwindSafe, EL: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,