MCPcopy Create free account
hub / github.com/douchuan/algorithm / check

Method check

src/graph/directed/cycle.rs:110–128  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

108 }
109
110 pub fn check(&self) -> Result<(), String> {
111 if let Some(cycle) = self.cycle() {
112 let mut first = -1;
113 let mut last = -1;
114 for &v in cycle {
115 if first == -1 {
116 first = v as i32;
117 }
118 last = v as i32;
119 }
120 if first != last {
121 return Err(format!(
122 "cycle begins with {} and ends with {}",
123 first, last
124 ));
125 }
126 }
127 Ok(())
128 }
129}
130
131impl EdgeWeightedDirectedCycle {

Callers

nothing calls this directly

Calls 5

ErrEnum · 0.85
is_noneMethod · 0.80
toMethod · 0.80
cycleMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected