-
Notifications
You must be signed in to change notification settings - Fork 0
/
community-query.html
80 lines (45 loc) · 5.75 KB
/
community-query.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis.css" type="text/css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis-network.min.js"> </script>
<center>
<h1></h1>
</center>
<!-- <link rel="stylesheet" href="../node_modules/vis/dist/vis.min.css" type="text/css" />
<script type="text/javascript" src="../node_modules/vis/dist/vis.js"> </script>-->
<style type="text/css">
#mynetwork {
width: 500px;
height: 500px;
background-color: #ffffff;
border: 1px solid lightgray;
position: relative;
float: left;
}
</style>
</head>
<body>
<div id = "mynetwork"></div>
<script type="text/javascript">
// initialize global variables.
var edges;
var nodes;
var network;
var container;
var options, data;
// This method is responsible for drawing the graph, returns the drawn network
function drawGraph() {
var container = document.getElementById('mynetwork');
// parsing and collecting nodes and edges from the python
nodes = new vis.DataSet([{"color": "green", "id": "7467.0", "label": "Query: 7467", "physics": false, "shape": "star", "size": 15, "title": "\u003cp\u003eKeywords:\u003c/p\u003e\u003col\u003e\u003cli\u003enofilter\u003c/li\u003e\u003cli\u003eshoppingaddict\u003c/li\u003e\u003cli\u003emadefromscratch\u003c/li\u003e\u003cli\u003egoodeats\u003c/li\u003e\u003cli\u003esunsout\u003c/li\u003e\u003cli\u003ebeautydoesnthavetobepain\u003c/li\u003e\u003cli\u003ehomemade\u003c/li\u003e\u003cli\u003ef4f\u003c/li\u003e\u003cli\u003ebestoftheday\u003c/li\u003e\u003cli\u003eilovemygadgets\u003c/li\u003e\u003cli\u003eapple\u003c/li\u003e\u003cli\u003efollow4follow\u003c/li\u003e\u003cli\u003eootd\u003c/li\u003e\u003c/ol\u003e", "x": 311, "y": 175}, {"color": "grey", "id": "1523.0", "label": "1523.0", "physics": false, "shape": "dot", "size": 15, "title": "\u003cp\u003eNumber of hops: 1\u003c/p\u003e\u003cp\u003eDistance: 1\u003c/p\u003e\u003cp\u003eDegree of Similarity:\u003c/p\u003e0.03333333333333333\u003cp\u003eCommon Keywords:\u003c/p\u003e\u003col\u003e\u003cli\u003ef4f\u003c/li\u003e\u003cli\u003eootd\u003c/li\u003e\u003cli\u003evegan\u003c/li\u003e\u003cli\u003ehomemade\u003c/li\u003e\u003cli\u003ebeautydoesnthavetobepain\u003c/li\u003e\u003cli\u003epicoftheday\u003c/li\u003e\u003cli\u003egoodeats\u003c/li\u003e\u003cli\u003efollow4follow\u003c/li\u003e\u003cli\u003ecatsofinstagram\u003c/li\u003e\u003cli\u003emadefromscratch\u003c/li\u003e\u003cli\u003ebestoftheday\u003c/li\u003e\u003cli\u003efoodporn\u003c/li\u003e\u003c/ol\u003e", "x": 40, "y": 14}, {"color": "grey", "id": "4371.0", "label": "4371.0", "physics": false, "shape": "dot", "size": 15, "title": "\u003cp\u003eNumber of hops: 2\u003c/p\u003e\u003cp\u003eDistance: 2\u003c/p\u003e\u003cp\u003eDegree of Similarity:\u003c/p\u003e0.008695652173913044\u003cp\u003eCommon Keywords:\u003c/p\u003e\u003col\u003e\u003cli\u003ef4f\u003c/li\u003e\u003cli\u003eootd\u003c/li\u003e\u003cli\u003etraveltuesday\u003c/li\u003e\u003cli\u003ehomemade\u003c/li\u003e\u003cli\u003emansbestfriend\u003c/li\u003e\u003cli\u003ebeautydoesnthavetobepain\u003c/li\u003e\u003cli\u003egoodeats\u003c/li\u003e\u003cli\u003efollow4follow\u003c/li\u003e\u003cli\u003emadefromscratch\u003c/li\u003e\u003cli\u003elove\u003c/li\u003e\u003cli\u003ebestoftheday\u003c/li\u003e\u003c/ol\u003e", "x": 245, "y": 161}, {"color": "grey", "id": "600.0", "label": "600.0", "physics": false, "shape": "dot", "size": 15, "title": "\u003cp\u003eNumber of hops: 3\u003c/p\u003e\u003cp\u003eDistance: 3\u003c/p\u003e\u003cp\u003eDegree of Similarity:\u003c/p\u003e0.08851063829787235\u003cp\u003eCommon Keywords:\u003c/p\u003e\u003col\u003e\u003cli\u003ef4f\u003c/li\u003e\u003cli\u003eootd\u003c/li\u003e\u003cli\u003ehomemade\u003c/li\u003e\u003cli\u003etechie\u003c/li\u003e\u003cli\u003ebeautydoesnthavetobepain\u003c/li\u003e\u003cli\u003egoodeats\u003c/li\u003e\u003cli\u003eresortwear\u003c/li\u003e\u003cli\u003efollow4follow\u003c/li\u003e\u003cli\u003emadefromscratch\u003c/li\u003e\u003cli\u003ebestoftheday\u003c/li\u003e\u003c/ol\u003e", "x": 428, "y": 500}, {"color": "blue", "id": "9225.0", "label": "9225.0", "physics": false, "shape": "dot", "size": 15, "title": "\u003cp\u003eNumber of hops: 4\u003c/p\u003e\u003cp\u003eDistance: 4\u003c/p\u003e\u003cp\u003eDegree of Similarity:\u003c/p\u003e0.08000000000000002\u003cp\u003eCommon Keywords:\u003c/p\u003e\u003col\u003e\u003cli\u003ef4f\u003c/li\u003e\u003cli\u003eootd\u003c/li\u003e\u003cli\u003ehomemade\u003c/li\u003e\u003cli\u003esunsout\u003c/li\u003e\u003cli\u003ebeautydoesnthavetobepain\u003c/li\u003e\u003cli\u003efoodie\u003c/li\u003e\u003cli\u003egoodeats\u003c/li\u003e\u003cli\u003einstastyle\u003c/li\u003e\u003cli\u003efollow4follow\u003c/li\u003e\u003cli\u003eshoppingaddict\u003c/li\u003e\u003cli\u003ecatsofinstagram\u003c/li\u003e\u003cli\u003emadefromscratch\u003c/li\u003e\u003cli\u003esun\u003c/li\u003e\u003cli\u003ebestoftheday\u003c/li\u003e\u003cli\u003elikeforlike\u003c/li\u003e\u003c/ol\u003e", "x": 175, "y": 29}]);
edges = new vis.DataSet([{"color": "black", "from": "7467.0", "to": "1523.0", "weight": 1}, {"color": "black", "from": "1523.0", "to": "4371.0", "weight": 1}, {"color": "black", "from": "4371.0", "to": "600.0", "weight": 1}, {"color": "black", "from": "600.0", "to": "9225.0", "weight": 1}]);
// adding nodes and edges to the graph
data = {nodes: nodes, edges: edges};
var options = {"layout": {"randomSeed": 2}};
network = new vis.Network(container, data, options);
return network;
}
drawGraph();
</script>
</body>
</html>