-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.html
More file actions
108 lines (73 loc) · 3.59 KB
/
graph.html
File metadata and controls
108 lines (73 loc) · 3.59 KB
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: 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": "#3452F9", "id": "1", "label": "1", "shape": "dot"}, {"color": "#F4D03F", "id": "12", "label": "12", "shape": "dot"}, {"color": "#35DE4E", "id": "2", "label": "2", "shape": "dot", "title": "30"}, {"color": "#35DE4E", "id": "3", "label": "3", "shape": "dot"}, {"color": "#35DE4E", "id": "4", "label": "4", "shape": "dot"}, {"color": "#35DE4E", "id": "5", "label": "5", "shape": "dot"}, {"color": "#35DE4E", "id": "6", "label": "6", "shape": "dot"}, {"color": "#E33440", "id": "7", "label": "7", "shape": "dot"}, {"color": "#E33440", "id": "8", "label": "8", "shape": "dot"}, {"color": "#E33440", "id": "9", "label": "9", "shape": "dot"}, {"color": "#E33440", "id": "10", "label": "10", "shape": "dot"}, {"color": "#E33440", "id": "11", "label": "11", "shape": "dot"}]);
edges = new vis.DataSet([{"arrows": "to", "color": "#35DE4E", "from": "1", "label": 1, "to": "2"}, {"arrows": "to", "color": "#35DE4E", "from": "2", "label": 1, "to": "3"}, {"arrows": "to", "color": "#35DE4E", "from": "3", "label": 1, "to": "4"}, {"arrows": "to", "color": "#35DE4E", "from": "4", "label": 1, "to": "5"}, {"arrows": "to", "color": "#35DE4E", "from": "5", "label": 1, "to": "6"}, {"arrows": "to", "color": "#35DE4E", "from": "6", "label": 1, "to": "12"}, {"arrows": "to", "from": "1", "label": "20", "to": "7", "weight": 20}, {"arrows": "to", "from": "7", "to": "8"}, {"arrows": "to", "from": "8", "to": "9"}, {"arrows": "to", "from": "9", "to": "10"}, {"arrows": "to", "from": "10", "to": "11"}, {"arrows": "to", "from": "11", "to": "12"}]);
// adding nodes and edges to the graph
data = {nodes: nodes, edges: edges};
var options = {
"configure": {
"enabled": false
},
"edges": {
"color": {
"inherit": false
},
"smooth": {
"enabled": true,
"type": "dynamic"
}
},
"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>