Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <queue>
- typedef std::vector<int> v_int;
- struct Road {
- int to;
- int in_way_time;
- explicit Road(int t = 0, int w = 0) {
- to = t;
- in_way_time = w;
- }
- };
- typedef std::vector<Road> v_road;
- typedef std::queue<int> q_int;
- struct CListGraph {
- explicit CListGraph(size_t num);
- void add_edge(int from, int to, int weight);
- size_t vertices_count() const;
- void get_next_vertices(int vertex, v_road &vertices) const;
- private:
- std::vector<v_road> vertices_list;
- void add_vertexes(int necessary_num);
- };
- struct For_A_Round {
- For_A_Round(size_t vertices_num, CListGraph *graph) {
- vertices_color.resize(vertices_num, false);
- my_graph = graph;
- vertices_dist.resize(vertices_num, vertices_num);
- }
- std::queue<q_int> queue_of_queues;
- std::vector<bool> vertices_color;
- v_int vertices_dist;
- CListGraph *my_graph;
- void get_next_vertices(int vertex, v_road &vertices) const;
- };
- void build_graph(CListGraph *my_graph, int num_of_edges) {
- int from = 0;
- int to = 0;
- int weight = 1;
- for (int i = 0; i < num_of_edges; ++ i) {
- std::cin >> from >> to >> weight;
- if (from != to) {
- my_graph->add_edge(to, from, weight);
- }
- }
- }
- void round(For_A_Round *my_round, int currrent_dist, int current_vertex) {
- v_road =
- }
- void find_the_shortest_way(CListGraph *my_graph, int from, int to) {
- For_A_Round my_round(my_graph->vertices_count(), my_graph);
- round(&my_round, 0, from);
- }
- int main() {
- std::cout << "Hello, World !" << std::endl;
- return 0;
- }
- CListGraph::CListGraph(size_t num) {
- vertices_list.resize(num);
- }
- void CListGraph::add_vertexes(int necessary_num) {
- while (vertices_list.size() < necessary_num + 1) {
- v_road new_vertex;
- vertices_list.push_back(new_vertex);
- }
- }
- void CListGraph::add_edge(int from, int to, int weight) {
- int necessary_num = std::max(from, to);
- if (vertices_list.size() < necessary_num + 1) {
- add_vertexes(necessary_num);
- }
- Road new_road(to, weight);
- Road new_reverse_road(from, weight);
- vertices_list[from].push_back(new_road);
- vertices_list[to].push_back(new_reverse_road);
- }
- size_t CListGraph::vertices_count() const {
- return vertices_list.size();
- }
- void CListGraph::get_next_vertices(int vertex, v_road &vertices) const {
- for (Road road_it : vertices_list[vertex]) {
- vertices.push_back(road_it);
- }
- }
- void For_A_Round::get_next_vertices(int vertex, v_road &vertices) const {
- v_road next_vertices;
- my_graph->get_next_vertices(vertex, next_vertices);
- for (Road road_it : next_vertices) {
- if (! vertices_color[road_it.to]) {
- vertices.push_back(road_it);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement