• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

networkit / networkit / 19529302360

20 Nov 2025 07:38AM UTC coverage: 79.387% (+0.2%) from 79.235%
19529302360

push

github

web-flow
Merge pull request #1360 from Schwarf/coverage/edge_scores

Add unit tests for class EdgeScoreAsWeight.

13 of 16 new or added lines in 2 files covered. (81.25%)

29424 of 37064 relevant lines covered (79.39%)

2282490.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.0
/networkit/cpp/edgescores/EdgeScore.cpp
1
/*
2
 * EdgeScore.cpp
3
 *
4
 *  Created on: 18.08.2015
5
 *      Author: Gerd Lindner
6
 */
7

8
#include <networkit/auxiliary/Log.hpp>
9
#include <networkit/edgescores/EdgeScore.hpp>
10

11
namespace NetworKit {
12

13
template <typename T>
14
EdgeScore<T>::EdgeScore(const Graph &G) : Algorithm(), G(&G), scoreData() {}
104✔
15

16
/** Compute the edge score. */
17
template <typename T>
18
void EdgeScore<T>::run() {
2✔
19
    // empty run method for edge scoring methods that do not require preprocessing but calculate
20
    // score(u,v) on the fly
21
    hasRun = true;
2✔
22
}
2✔
23

24
/** Get a vector containing the score for each edge in the graph.
25
 *
26
 * @return the edge scores calculated by @link run().
27
 */
28
template <typename T>
29
const std::vector<T> &EdgeScore<T>::scores() const {
78✔
30
    assureFinished();
78✔
31
    return scoreData;
76✔
32
}
33

34
/** Get the edge score of the edge with the given edge id.
35
 */
36
template <typename T>
37
T EdgeScore<T>::score(edgeid eid) {
20✔
38
    assureFinished();
20✔
39
    return scoreData[eid];
16✔
40
}
41

42
/** Get the edge score of the given edge.
43
 */
44
template <typename T>
45
T EdgeScore<T>::score(node u, node v) {
10✔
46
    return score(G->edgeId(u, v));
10✔
47
}
48

49
template <typename T>
50
Graph EdgeScore<T>::calculate(bool squared, edgeweight offset, edgeweight factor) const {
10✔
51
    assureFinished();
10✔
52

53
    if (!G->hasEdgeIds()) {
8✔
54
        throw std::runtime_error("Edges have not been indexed - call indexEdges first");
2✔
55
    }
56

57
    Graph result(*G, true, G->isDirected());
6✔
58

59
    if (squared) {
6✔
60
        G->parallelForEdges([&](node u, node v, edgeid eid) {
8✔
61
            const auto s = scoreData[eid];
2✔
62
            result.setWeight(u, v, offset + factor * s * s);
2✔
63
        });
64
    } else {
65
        G->parallelForEdges([&](node u, node v, edgeid eid) {
12✔
66
            result.setWeight(u, v, offset + factor * scoreData[eid]);
4✔
67
        });
68
    }
69
    return result;
6✔
NEW
70
}
×
71

72
template class EdgeScore<double>;
73
template class EdgeScore<count>;
74

75
} /* namespace NetworKit */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc