All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TiledGraphEdge.h
1 #pragma once
2 
3 #include "Graphs.h"
4 #include "TiledGraphNode.h"
5 #include <sstream>
6 
7 namespace Eegeo
8 {
9  namespace Graphs
10  {
12  {
14  : CellKey(Eegeo::Streaming::MortonKey(0))
15  , LocalEdgeId(-1)
16  {}
17 
19  const Eegeo::Streaming::MortonKey& cellKey,
20  int localEdgeId
21  )
22  : CellKey(cellKey)
23  , LocalEdgeId(localEdgeId)
24  {}
25 
27  : CellKey(other.CellKey)
28  , LocalEdgeId(other.LocalEdgeId)
29  {}
30 
31 
33  int LocalEdgeId;
34  };
35 
36  inline bool operator == (const TiledGraphEdgeId& lhs, const TiledGraphEdgeId& rhs)
37  {
38  return (lhs.LocalEdgeId == rhs.LocalEdgeId) &&
39  (lhs.CellKey == rhs.CellKey);
40  }
41 
42  inline std::string TiledGraphEdgeIdToString(const TiledGraphEdgeId& edgeId)
43  {
44  std::stringstream ss;
45  ss << edgeId.CellKey.ToString() << ":" << edgeId.LocalEdgeId;
46  return ss.str();
47  }
48 
50  {
51  std::size_t operator()(const TiledGraphEdgeId& edgeId) const
52  {
53  std::size_t h1 = Eegeo::Streaming::MortonKeyHash{}(edgeId.CellKey);
54  std::size_t h2 = std::hash<int>{}(edgeId.LocalEdgeId);
55  return h1 ^ (h2 << 1);
56  }
57  };
58 
60  {
62  : Weight(0.f)
63  , AttributesDirectionReversed(false)
64  {}
65 
67  const TiledGraphNodeId& nodeIdA,
68  const TiledGraphNodeId& nodeIdB,
69  const TiledGraphEdgeAttributesId& attributesId,
70  float weight,
71  bool attributesDirectionReversed
72  )
73  : NodeIdA(nodeIdA)
74  , NodeIdB(nodeIdB)
75  , AttributesId(attributesId)
76  , Weight(weight)
77  , AttributesDirectionReversed(attributesDirectionReversed)
78  {}
79 
80  TiledGraphNodeId NodeIdA;
81  TiledGraphNodeId NodeIdB;
82  TiledGraphEdgeAttributesId AttributesId;
83  float Weight;
84  bool AttributesDirectionReversed;
85  };
86 
87  inline bool operator == (const TiledGraphEdge& lhs, const TiledGraphEdge& rhs)
88  {
89  return (lhs.NodeIdA == rhs.NodeIdA) &&
90  (lhs.NodeIdB == rhs.NodeIdB) &&
91  (lhs.AttributesId == rhs.AttributesId) &&
92  (lhs.Weight == rhs.Weight) &&
93  (lhs.AttributesDirectionReversed == rhs.AttributesDirectionReversed);
94  }
95  }
96 }