forked from seanjaffe1/PA2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGraphTest.cpp
52 lines (33 loc) · 1.24 KB
/
GraphTest.cpp
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
#include "GraphHelper.h"
#include "FeatureGraph.h"
#include "GraphAnalyzer.h"
#include <map>
#include <iostream>
using namespace std;
int main() {
vector<Node> nodes {
Node(1, vector<float> { 10, 10}),
Node(2,vector<float> { 20, 20}),
Node(3, vector<float> { 30, 30}),
Node(4, vector<float> { 40, 40}) };
vector<Edge> edges {Edge(1,2, 10), Edge(2, 3, 9), Edge(3, 4, 1), Edge(1, 3, 5)};
int d = 2;
FeatureGraph graph = FeatureGraph(4, d, nodes, edges);
GraphAnalyzer analyzer = GraphAnalyzer(graph);
cout << analyzer.diameter() << "\n";
cout << analyzer.openClosedTriangleRatio() << "\n";
cout << analyzer.topKOpenTriangles(2) << "\n";
int newNodeID = 5;
vector<float> newFeatures {3, 3};
Node newNode = Node(newNodeID, newFeatures);
analyzer.insert(newNode);
analyzer.insert(Edge(4, 5, 32));
vector<float> weights{.5, .5};
vector<int> neighbors = analyzer.topKNeighbors(2, 3, weights);
for(auto i = neighbors.begin(); i != neighbors.end(); ++i)
cout << *i << ",";
cout << "\n";
cout << analyzer.topNonNeighbor(2, weights) << "\n";
cout << analyzer.jacardIndexOfTopKNeighborhoods(1, 2, 2, weights);
return 0;
}