Created
February 22, 2015 07:25
-
-
Save anonymous/a36f5e3569416d336f15 to your computer and use it in GitHub Desktop.
Cytoscape.js initialisation // source http://jsbin.com/soyeyexaka
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="style.css" rel="stylesheet" /> | |
<meta charset=utf-8 /> | |
<title>Cytoscape.js initialisation</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://cytoscape.github.io/cytoscape.js/api/cytoscape.js-latest/cytoscape.min.js"></script> | |
<script src="code.js"></script> | |
<style id="jsbin-css"> | |
body { | |
font: 14px helvetica neue, helvetica, arial, sans-serif; | |
} | |
#cy { | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
left: 0; | |
top: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="cy"></div> | |
<script id="jsbin-javascript"> | |
$(function(){ // on dom ready | |
var cy = cytoscape({ | |
container: document.getElementById('cy'), | |
style: cytoscape.stylesheet() | |
.selector('node') | |
.css({ | |
'content': 'data(id)' | |
}) | |
.selector('edge') | |
.css({ | |
'target-arrow-shape': 'triangle', | |
'width': 4, | |
'line-color': '#ddd', | |
'target-arrow-color': '#ddd' | |
}) | |
.selector('.highlighted') | |
.css({ | |
'background-color': '#61bffc', | |
'line-color': '#61bffc', | |
'target-arrow-color': '#61bffc', | |
'transition-property': 'background-color, line-color, target-arrow-color', | |
'transition-duration': '0.0s' | |
}), | |
elements: { | |
nodes: [ | |
{ data: { id: '1' } }, | |
{ data: { id: '2' } }, | |
{ data: { id: '3' } }, | |
], | |
edges: [ | |
{ data: { id: 'a"e', weight: 1, source: '1', target: '2' } }, | |
{ data: { id: 'ab', weight: 3, source: '2', target: '1' } }, | |
{ data: { id: 'be', weight: 4, source: '2', target: '3' } }, | |
{ data: { id: 'bc', weight: 5, source: '3', target: '1' } }, | |
] | |
}, | |
layout: { | |
name: 'breadthfirst', | |
directed: true, | |
roots: '#a', | |
padding: 10 | |
} | |
}); | |
var bfs = cy.elements().bfs('#a', function(){}, true); | |
var i = 0; | |
var highlightNextEle = function(){ | |
bfs.path[i].addClass('highlighted'); | |
if( i < bfs.path.length ){ | |
i++; | |
setTimeout(highlightNextEle, 1000); | |
} | |
}; | |
// kick off first highlight | |
highlightNextEle(); | |
}); // on dom ready | |
</script> | |
<script id="jsbin-source-css" type="text/css">body { | |
font: 14px helvetica neue, helvetica, arial, sans-serif; | |
} | |
#cy { | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
left: 0; | |
top: 0; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">$(function(){ // on dom ready | |
var cy = cytoscape({ | |
container: document.getElementById('cy'), | |
style: cytoscape.stylesheet() | |
.selector('node') | |
.css({ | |
'content': 'data(id)' | |
}) | |
.selector('edge') | |
.css({ | |
'target-arrow-shape': 'triangle', | |
'width': 4, | |
'line-color': '#ddd', | |
'target-arrow-color': '#ddd' | |
}) | |
.selector('.highlighted') | |
.css({ | |
'background-color': '#61bffc', | |
'line-color': '#61bffc', | |
'target-arrow-color': '#61bffc', | |
'transition-property': 'background-color, line-color, target-arrow-color', | |
'transition-duration': '0.0s' | |
}), | |
elements: { | |
nodes: [ | |
{ data: { id: '1' } }, | |
{ data: { id: '2' } }, | |
{ data: { id: '3' } }, | |
], | |
edges: [ | |
{ data: { id: 'a"e', weight: 1, source: '1', target: '2' } }, | |
{ data: { id: 'ab', weight: 3, source: '2', target: '1' } }, | |
{ data: { id: 'be', weight: 4, source: '2', target: '3' } }, | |
{ data: { id: 'bc', weight: 5, source: '3', target: '1' } }, | |
] | |
}, | |
layout: { | |
name: 'breadthfirst', | |
directed: true, | |
roots: '#a', | |
padding: 10 | |
} | |
}); | |
var bfs = cy.elements().bfs('#a', function(){}, true); | |
var i = 0; | |
var highlightNextEle = function(){ | |
bfs.path[i].addClass('highlighted'); | |
if( i < bfs.path.length ){ | |
i++; | |
setTimeout(highlightNextEle, 1000); | |
} | |
}; | |
// kick off first highlight | |
highlightNextEle(); | |
}); // on dom ready</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font: 14px helvetica neue, helvetica, arial, sans-serif; | |
} | |
#cy { | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
left: 0; | |
top: 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ // on dom ready | |
var cy = cytoscape({ | |
container: document.getElementById('cy'), | |
style: cytoscape.stylesheet() | |
.selector('node') | |
.css({ | |
'content': 'data(id)' | |
}) | |
.selector('edge') | |
.css({ | |
'target-arrow-shape': 'triangle', | |
'width': 4, | |
'line-color': '#ddd', | |
'target-arrow-color': '#ddd' | |
}) | |
.selector('.highlighted') | |
.css({ | |
'background-color': '#61bffc', | |
'line-color': '#61bffc', | |
'target-arrow-color': '#61bffc', | |
'transition-property': 'background-color, line-color, target-arrow-color', | |
'transition-duration': '0.0s' | |
}), | |
elements: { | |
nodes: [ | |
{ data: { id: '1' } }, | |
{ data: { id: '2' } }, | |
{ data: { id: '3' } }, | |
], | |
edges: [ | |
{ data: { id: 'a"e', weight: 1, source: '1', target: '2' } }, | |
{ data: { id: 'ab', weight: 3, source: '2', target: '1' } }, | |
{ data: { id: 'be', weight: 4, source: '2', target: '3' } }, | |
{ data: { id: 'bc', weight: 5, source: '3', target: '1' } }, | |
] | |
}, | |
layout: { | |
name: 'breadthfirst', | |
directed: true, | |
roots: '#a', | |
padding: 10 | |
} | |
}); | |
var bfs = cy.elements().bfs('#a', function(){}, true); | |
var i = 0; | |
var highlightNextEle = function(){ | |
bfs.path[i].addClass('highlighted'); | |
if( i < bfs.path.length ){ | |
i++; | |
setTimeout(highlightNextEle, 1000); | |
} | |
}; | |
// kick off first highlight | |
highlightNextEle(); | |
}); // on dom ready |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment