SimmelianScore.h
Go to the documentation of this file.
1 /*
2  * SimmelianAttributizer.h
3  *
4  * Created on: 21.05.2014
5  * Author: Gerd Lindner
6  */
7
8 #ifndef SIMMELIANATTRIBUTIZER_H_
9 #define SIMMELIANATTRIBUTIZER_H_
10
11 #include "../edgescores/EdgeScore.h"
12 #include <set>
13
14 namespace NetworKit {
15
21 struct RankedEdge {
24  count simmelianness; //The number of triangles the edge is embedded in.
25  count rank; //The rank within the ranked neighborhood.
26
28  ego(ego), alter(alter), simmelianness(s), rank(0) {
29  }
30
32  ego(ego), alter(alter), simmelianness(s), rank(r) {
33  }
34
35  bool operator<(const RankedEdge& other) const {
36  return (simmelianness > other.simmelianness)
37  || (simmelianness == other.simmelianness && alter > other.alter);
38  }
39
40  bool operator>(const RankedEdge& other) const {
41  return (simmelianness < other.simmelianness)
42  || (simmelianness == other.simmelianness && alter < other.alter);
43  }
44
45  bool operator==(const RankedEdge& other) const {
46  return ego == other.ego && simmelianness == other.simmelianness
47  && alter == other.alter && rank == other.rank;
48  }
49 };
50
51 typedef std::vector<RankedEdge> RankedNeighbors;
52
57 struct Redundancy {
59  double jaccard;
60
61  Redundancy(count o, double j) : overlap(o), jaccard(j) { }
62 };
63
67 class SimmelianScore : public EdgeScore<double> {
68
69 public:
70
71  SimmelianScore(const Graph& graph, const std::vector<count>& attribute);
72  virtual double score(edgeid eid) override;
73  virtual double score(node u, node v) override;
74
75  std::vector<RankedNeighbors> getRankedNeighborhood(const Graph& g, const std::vector<count>& triangles);
76
78  const node& ego,
79  const node& alter,
80  const std::vector<RankedNeighbors>& neighbors,
81  const count& maxRank);
82
83  void matchNeighbors(
84  const node& ego,
85  const node& alter,
86  const bool& reciprocityCheck,
87  std::vector<RankedEdge>::const_iterator& egoIt,
88  const RankedNeighbors& egoNeighbors,
89  std::set<node>& egoNeighborsUnmatched,
90  std::set<node>& alterNeighborsUnmatched,
91  const count& rank,
92  count& overlap);
93
94 protected:
95  const std::vector<count>& triangles;
96
97 };
98
99 } /* namespace NetworKit */
100
101 #endif /* SIMMELIANSCORE_H_ */
double jaccard
Definition: SimmelianScore.h:59
Redundancy(count o, double j)
Definition: SimmelianScore.h:61
A directed edge with a simmelianness int value.
Definition: SimmelianScore.h:21
RankedEdge(node ego, node alter, count s)
Definition: SimmelianScore.h:27
index edgeid
Definition: Globals.h:25
Redundancy getOverlap(const node &ego, const node &alter, const std::vector< RankedNeighbors > &neighbors, const count &maxRank)
Definition: SimmelianScore.cpp:48
const std::vector< count > & triangles
Definition: SimmelianScore.h:95
count rank
Definition: SimmelianScore.h:25
node alter
Definition: SimmelianScore.h:23
node ego
Definition: SimmelianScore.h:22
void matchNeighbors(const node &ego, const node &alter, const bool &reciprocityCheck, std::vector< RankedEdge >::const_iterator &egoIt, const RankedNeighbors &egoNeighbors, std::set< node > &egoNeighborsUnmatched, std::set< node > &alterNeighborsUnmatched, const count &rank, count &overlap)
Helper function used in getOverlap.
Definition: SimmelianScore.cpp:79
std::vector< RankedEdge > RankedNeighbors
Definition: SimmelianScore.h:51
virtual double score(edgeid eid) override
Get the edge score of the edge with the given edge id.
Definition: SimmelianScore.cpp:107
bool operator==(const RankedEdge &other) const
Definition: SimmelianScore.h:45
uint64_t count
Definition: Globals.h:21
index node
Definition: Globals.h:23
bool operator>(const RankedEdge &other) const
Definition: SimmelianScore.h:40
count simmelianness
Definition: SimmelianScore.h:24
std::vector< RankedNeighbors > getRankedNeighborhood(const Graph &g, const std::vector< count > &triangles)
Definition: SimmelianScore.cpp:16
RankedEdge(node ego, node alter, count s, count r)
Definition: SimmelianScore.h:31
A graph (with optional weights) and parallel iterator methods.
Definition: Graph.h:79
Abstract base class for the two variants of Simmelian backbones (OverlapFilter, JaccardFilter).
Definition: SimmelianScore.h:67
bool operator<(const RankedEdge &other) const
Definition: SimmelianScore.h:35
count overlap
Definition: SimmelianScore.h:58
Represents the result of the comparison of two ranked neighborhood lists, namely the overlap of the t...
Definition: SimmelianScore.h:57
SimmelianScore(const Graph &graph, const std::vector< count > &attribute)
Definition: SimmelianScore.cpp:13
Abstract base class for an edge score.
Definition: EdgeScore.h:20