Initial release #1
+1
-6
@@ -6,12 +6,7 @@ use models::Vertex;
|
||||
|
||||
fn main() {
|
||||
// TODO: Move this graph example into one or more tests.
|
||||
let mut graph = Graph {
|
||||
// TODO: The initializations should happen in an initializer or constructor
|
||||
incidence_headers: vec![],
|
||||
next_incidences: vec![],
|
||||
incidence_vertices: vec![],
|
||||
};
|
||||
let mut graph = Graph::new();
|
||||
let vertices: [Vertex; 10] = core::array::from_fn(|_| graph.add_vertex());
|
||||
graph.add_edge(vertices[0], vertices[1]);
|
||||
graph.add_edge(vertices[1], vertices[2]);
|
||||
|
||||
@@ -26,6 +26,14 @@ pub struct Graph {
|
||||
// TODO: Add iterator of edges.
|
||||
// TODO: Add iterator of vertex neighbors, see 'fn add_adjacent()'.
|
||||
impl Graph {
|
||||
pub fn new() -> Graph {
|
||||
Graph {
|
||||
incidence_headers: vec![],
|
||||
next_incidences: vec![],
|
||||
incidence_vertices: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vertex_count(&self) -> usize {
|
||||
self.incidence_headers.len()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user