-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathWeightMultiGraph.h
51 lines (42 loc) · 1.39 KB
/
WeightMultiGraph.h
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
//
// WeightMultiGraph.h
// Graphoffline
//
// Created by Олег on 03.01.2020.
//
#pragma once
#include <stdio.h>
#include "IGraph.h"
#include "Graph.h"
#include "MultiGraph.h"
template<class WeightInterface, typename WeightTmplType> class WeightMultiGraph : public MultiGraph, public virtual WeightInterface
{
public:
static WeightInterface* CreateGraph(const IGraph* graph)
{
const Graph* pGraph = dynamic_cast<const Graph*>(graph);
return pGraph ? dynamic_cast<WeightMultiGraph*>(pGraph->MakeGraphCopy(GCT_COPY, &WeightMultiGraph::CreateGraphStatic)) : nullptr;
}
// Get Egde weight of int graph.
virtual WeightTmplType GetEdgeWeight(ObjectId edgeId) const override
{
const auto edge = GetEdgeById(edgeId);
return edge ? edge->template GetWeight<WeightTmplType>() : WeightTmplType();
}
// Create copy of graph.
virtual WeightInterface* MakeCopy(GraphCopyType type) const override
{
return (WeightInterface*)MakeGraphCopy(type);
}
protected:
Graph* CreateGraph() const override
{
return CreateGraphStatic();
}
static Graph* CreateGraphStatic()
{
return new WeightMultiGraph<WeightInterface, WeightTmplType>();
}
};
using IntMultiGraph = WeightMultiGraph<IMultiGraphInt, IntWeightType>;
using FloatMultiGraph = WeightMultiGraph<IMultiGraphFloat, FloatWeightType>;