From e18b31eece6e17ba8e41dc1a69f6b2a27fcd92c0 Mon Sep 17 00:00:00 2001 From: doryan04 Date: Sun, 17 Sep 2023 21:21:14 +0400 Subject: [PATCH] I begin create a Graph structure --- .gitignore | 1 + .idea/.gitignore | 8 +++++++ .idea/modules.xml | 8 +++++++ .idea/untitled.iml | 11 ++++++++++ .idea/vcs.xml | 6 ++++++ Cargo.lock | 7 ++++++ Cargo.toml | 8 +++++++ src/main.rs | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 102 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/untitled.iml create mode 100644 .idea/vcs.xml create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..aeb7613 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/untitled.iml b/.idea/untitled.iml new file mode 100644 index 0000000..cf84ae4 --- /dev/null +++ b/.idea/untitled.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..ccfeb2c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "untitled" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..62ea391 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "untitled" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c52d54c --- /dev/null +++ b/src/main.rs @@ -0,0 +1,53 @@ +mod graph { + + use std::collections::{HashMap, HashSet}; + use std::vec::Vec; + + pub struct Graph { + frame_graph : HashMap>, + flags_graph : HashSet<(u32, bool)> + } + + impl Graph { + + pub fn new() -> Graph { + Graph{ + frame_graph : HashMap::new(), + flags_graph : HashSet::new(), + } + } + + pub fn add(&mut self, parent : u32, children : Vec){ + + self.frame_graph.insert(parent, children); + self.flags_graph.insert((parent, false)); + for &i in self.frame_graph.get(&parent).unwrap() { + self.flags_graph.insert((i, false)); + } + + } + + pub fn get(&self) -> &Graph { + self.clone() + } + + } +} + +mod new_class{ + + use super::graph; + +} + + +fn main(){ + + use crate::graph::Graph; + + let mut graph : Graph = Graph::new(); + graph.add(1, vec![2, 3, 4]); + graph.add(2, vec![9, 7, 6, 1]); + graph.add(6, vec![12, 11, 19]); + +} \ No newline at end of file