-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathD.html
108 lines (73 loc) · 3.6 KB
/
D.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<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: 800px;
height: 800px;
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": "orange", "id": "proc 0", "label": "proc 0", "shape": "dot"}, {"color": "blue", "id": "user 0", "label": "user 0", "shape": "dot"}, {"color": "blue", "id": "user 1", "label": "user 1", "shape": "dot"}, {"color": "blue", "id": "user 2", "label": "user 2", "shape": "dot"}, {"color": "blue", "id": "user 3", "label": "user 3", "shape": "dot"}, {"color": "blue", "id": "user 4", "label": "user 4", "shape": "dot"}, {"color": "blue", "id": "user 5", "label": "user 5", "shape": "dot"}, {"color": "orange", "id": "proc 1", "label": "proc 1", "shape": "dot"}]);
edges = new vis.DataSet([{"from": "user 0", "label": "9", "length": 187.69933473201377, "to": "proc 0"}, {"from": "user 1", "label": "7", "length": 158.51319380084183, "to": "proc 0"}, {"from": "user 2", "label": "2", "length": 40.03104988174485, "to": "proc 0"}, {"from": "user 3", "label": "2", "length": 49.228988038040235, "to": "proc 0"}, {"from": "user 4", "label": "2", "length": 40.72775289176222, "to": "proc 0"}, {"from": "user 5", "label": "3", "length": 68.11497436161704, "to": "proc 0"}, {"from": "user 0", "label": "5", "length": 103.58084386635822, "to": "proc 1"}, {"from": "user 1", "label": "5", "length": 114.22781881917916, "to": "proc 1"}, {"from": "user 2", "label": "4", "length": 86.38948547450441, "to": "proc 1"}, {"from": "user 3", "label": "3", "length": 68.50522955526522, "to": "proc 1"}, {"from": "user 4", "label": "5", "length": 115.41286782556304, "to": "proc 1"}, {"from": "user 5", "label": "7", "length": 146.83195964204305, "to": "proc 1"}]);
// adding nodes and edges to the graph
data = {nodes: nodes, edges: edges};
var options = {
"configure": {
"enabled": false
},
"edges": {
"color": {
"inherit": true
},
"smooth": {
"enabled": false,
"type": "continuous"
}
},
"interaction": {
"dragNodes": true,
"hideEdgesOnDrag": false,
"hideNodesOnDrag": false
},
"physics": {
"enabled": true,
"stabilization": {
"enabled": true,
"fit": true,
"iterations": 1000,
"onlyDynamicEdges": false,
"updateInterval": 50
}
}
};
network = new vis.Network(container, data, options);
return network;
}
drawGraph();
</script>
</body>
</html>