-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathReverseGraph.h
More file actions
68 lines (57 loc) · 1.68 KB
/
ReverseGraph.h
File metadata and controls
68 lines (57 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Author : XuBenHao
// Version : 1.0.0
// Mail : xbh370970843@163.com
// Copyright : XuBenHao 2020 - 2030
#ifndef AILIB_ALGORITHM_GRAPH_REVERSEGRAPH_H
#define AILIB_ALGORITHM_GRAPH_REVERSEGRAPH_H
#include "..\..\stdafx.h"
#include "..\..\DataStruct\Graph\Graph.h"
namespace AlLib
{
namespace Algorithm
{
namespace Graph
{
template<typename Key, typename Value>
class ReverseGraph
{
public:
typename typedef DataStruct::GraphStruct::Graph<Key, Value> InnerGraph;
ReverseGraph(const InnerGraph& nGraph_);
~ReverseGraph();
InnerGraph Run();
private:
ReverseGraph(const ReverseGraph& nGraph_) = default;
ReverseGraph& operator=(const ReverseGraph& nGraph_) = default;
private:
const InnerGraph& m_nGraph;
};
template<typename Key, typename Value>
ReverseGraph<Key, Value>::ReverseGraph(const InnerGraph& nGraph_)
: m_nGraph(nGraph_)
{
}
template<typename Key, typename Value>
ReverseGraph<Key, Value>::~ReverseGraph()
{
}
template<typename Key, typename Value>
typename DataStruct::GraphStruct::Graph<Key, Value> ReverseGraph<Key, Value>::Run()
{
InnerGraph _nGraph;
DataStruct::Array::DynArray<typename InnerGraph::Node*> _arrNodes = m_nGraph.GetNodesArray();
for (int _i = 0; _i < _arrNodes.GetSize(); _i++)
{
_nGraph.AddNode(_arrNodes[_i]->GetPair());
}
DataStruct::Array::DynArray<typename InnerGraph::Edge*> _arrEdges = m_nGraph.GetEdgesArray();
for (int _i = 0; _i < _arrEdges.GetSize(); _i++)
{
_nGraph.AddEdge(_arrEdges[_i]->GetIdentity().Reverse());
}
return _nGraph;
}
}
}
}
#endif