pub struct Graph { /* private fields */ }
Expand description
A resolved demes Graph.
Instances of this type will be fully-resolved according to the machine data model described here.
A graph cannot be directly initialized. See:
Implementations§
source§impl Graph
impl Graph
sourcepub fn get_deme_from_name(&self, name: &str) -> Option<&Deme>
👎Deprecated: Use Graph::get_deme instead
pub fn get_deme_from_name(&self, name: &str) -> Option<&Deme>
sourcepub fn generation_time(&self) -> GenerationTime
pub fn generation_time(&self) -> GenerationTime
Get the GenerationTime
for the graph.
sourcepub fn time_units(&self) -> TimeUnits
pub fn time_units(&self) -> TimeUnits
Get the TimeUnits
for the graph.
sourcepub fn migrations(&self) -> &[AsymmetricMigration]
pub fn migrations(&self) -> &[AsymmetricMigration]
Get the migration events for the graph.
sourcepub fn into_generations(self) -> Result<Self, DemesError>
pub fn into_generations(self) -> Result<Self, DemesError>
Convert the time units to generations.
§Errors
If the time unit of an event differs sufficiently in
magnitude from the generation_time
, it is possible
that conversion results in epochs (or migration
durations) of length zero, which will return an error.
If any field is unresolved, an error will be returned.
sourcepub fn into_integer_generations(self) -> Result<Graph, DemesError>
pub fn into_integer_generations(self) -> Result<Graph, DemesError>
Convert the time units to generations, rounding the output to an integer value.
sourcepub fn into_generations_with(
self,
with: fn(_: Time, _: GenerationTime) -> Time
) -> Result<Graph, DemesError>
pub fn into_generations_with( self, with: fn(_: Time, _: GenerationTime) -> Time ) -> Result<Graph, DemesError>
Convert the time units to generations with a callback to specify the conversion policy
sourcepub fn as_string(&self) -> Result<String, DemesError>
pub fn as_string(&self) -> Result<String, DemesError>
Return a representation of the graph as a string.
The format is in YAML and corresponds to the MDM representation of the data.
§Error
Will return an error if serde_yaml::to_string
returns an error.
sourcepub fn as_json_string(&self) -> Result<String, DemesError>
Available on crate feature json
only.
pub fn as_json_string(&self) -> Result<String, DemesError>
json
only.Return a representation of the graph as a string.
The format is in JSON and corresponds to the MDM representation of the data.
§Error
Will return an error if serde_json::to_string
returns an error.
sourcepub fn most_recent_deme_end_time(&self) -> Time
pub fn most_recent_deme_end_time(&self) -> Time
Return the most recent end time of any deme in the Graph.
This function is useful to check if the most recent end time is greater than zero, meaning that the model ends at a time point ancestral to “now”.
sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Return the description field.
sourcepub fn has_non_integer_sizes(&self) -> Option<(&str, usize)>
pub fn has_non_integer_sizes(&self) -> Option<(&str, usize)>
Check if any epochs have non-integer
start_size
or end_size
.
§Returns
- The deme name and epoch index where the first non-integer value is encountered
- None if non non-integer values are encountered
sourcepub fn into_integer_start_end_sizes(self) -> Result<Self, DemesError>
pub fn into_integer_start_end_sizes(self) -> Result<Self, DemesError>
Round all epoch start/end sizes to nearest integer value.
§Returns
A modified graph with rounded sizes.
§Error
EpochError
if rounding leads to a value of 0.
§Note
Rounding uses f64::round
Trait Implementations§
source§impl PartialEq for Graph
impl PartialEq for Graph
impl Eq for Graph
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.