在加权图中创建addvertex函数

时间:2018-05-09 14:38:24

标签: c++ graph weighted-graph

下面是我当前的代码,我在实现addvertex函数时遇到了麻烦,我不太清楚从哪里开始,因为我对c ++很新,任何帮助都会受到赞赏。我被告知使用地图将是最简单的方法。

图形需要计算最小生成树,深度和广度优先遍历以及实现迭代器。

addvertex函数会将传递的顶点添加到图形中(没有边缘)。

#ifndef WEIGHTED_GRAPH_H
#define WEIGHTED_GRAPH_H

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <array>
#include <list>
#include <forward_list>
#include <deque>
#include <map>

template <typename vertex>
class weighted_graph {
    private:
    class graph_iterator {
        private:
        public:
            graph_iterator(const weighted_graph &);
            graph_iterator(const weighted_graph &, size_t);
            ~graph_iterator();
            graph_iterator operator=(const graph_iterator&);
            bool operator==(const graph_iterator&) const;
            bool operator!=(const graph_iterator&) const;
            graph_iterator operator++();
            graph_iterator operator++(int);
            const vertex operator*();
            const vertex* operator->();
    };

    class neighbour_iterator {
        private:
        public:
            neighbour_iterator(const neighbour_iterator&);
            neighbour_iterator(const weighted_graph &, const vertex&);
            neighbour_iterator(const weighted_graph &, const vertex&, size_t);
            ~neighbour_iterator();
            neighbour_iterator operator=(const neighbour_iterator& it);
            bool operator==(const neighbour_iterator&) const;
            bool operator!=(const neighbour_iterator&) const;
            neighbour_iterator operator++();
            neighbour_iterator operator++(int);         
            const std::pair<vertex, int> operator*();
            const std::pair<const vertex, int>* operator->();
    };

    public:


    weighted_graph(); 
    ~weighted_graph();

    void add_vertex(const vertex&);

0 个答案:

没有答案