1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #pragma once
- #include <string>
- #include <map>
- #include <set>
- #include <fstream>
- #include <vector>
- #include <iostream>
- using namespace std;
- class Graph_exception {};
- class GraphNode {
- typedef set<GraphNode*>::const_iterator node_iterator;
- private:
- string name;
- set <GraphNode*> neighbors;
- void add_neigbor(GraphNode* neighboor);
- void remove_neighbor(GraphNode* neighboor);
- public:
- GraphNode();
- GraphNode(const string& aname);
- const string get_name() const;
- node_iterator nb_begin() const {
- return neighbors.begin();
- };
- node_iterator nb_end() const {
- return neighbors.end();
- };
- const bool& operator == (const GraphNode& r);
- friend class Graph;
- };
- class Graph
- {
- typedef set<GraphNode*>::const_iterator node_iterator;
- private:
- map <string, bool> taken_names;
- map <string, GraphNode> saved;
- set<GraphNode*> nodes;
- void write_graph(vector <vector <node_iterator> > ind);
- public:
- Graph() {};
- void add_node(GraphNode* node);
- void remove_node(GraphNode* node);
- void add_edge(GraphNode* begin, GraphNode* end);
- void remove_edge(GraphNode* begin, GraphNode* end);
- static Graph read_file(const string& file_name);
- void find_independent_graphs();
- node_iterator begin() {
- return nodes.begin();
- };
- node_iterator end() {
- return nodes.end();
- };
- friend class Node;
- };
|