mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Adding Depth First Search for cytoscape graphs
This commit is contained in:
@@ -94,9 +94,9 @@ define(function() { return /******/ (function(modules) { // webpackBootstrap
|
||||
}
|
||||
},
|
||||
{
|
||||
selector: '.bfspath',
|
||||
selector: '.searchpath',
|
||||
style: {
|
||||
'background-color': '#336699', // #61bffc
|
||||
'background-color': '#336699',
|
||||
'line-color': '#336699',
|
||||
'target-arrow-color': '#336699',
|
||||
'transition-property': 'background-color, line-color, target-arrow-color',
|
||||
@@ -108,9 +108,10 @@ define(function() { return /******/ (function(modules) { // webpackBootstrap
|
||||
|
||||
// Register tap event on graph nodes
|
||||
// Right now on tapping on any node, BFS starts from that node
|
||||
cytoscape.$('node').on('tap', function( e ) {
|
||||
var ele = e.cyTarget;
|
||||
self.run_bfs(cytoscape, ele.id());
|
||||
cytoscape.$( 'node' ).on('tap', function( e ) {
|
||||
var ele = e.cyTarget,
|
||||
search_algorithm = settings.get( 'search_algorithm' );
|
||||
self.run_search_algorithm(cytoscape, ele.id(), search_algorithm);
|
||||
});
|
||||
|
||||
chart.state( 'ok', 'Chart drawn.' );
|
||||
@@ -127,13 +128,21 @@ define(function() { return /******/ (function(modules) { // webpackBootstrap
|
||||
}
|
||||
});
|
||||
},
|
||||
run_bfs: function( cytoscape, root_id ) {
|
||||
var bfs = cytoscape.elements().bfs('#' + root_id, function(){}, true);
|
||||
var i = 0, timeOut = 1500;
|
||||
run_search_algorithm: function( cytoscape, root_id, type ) {
|
||||
var algorithm = "", i = 0, timeOut = 1500;
|
||||
if( type === "bfs" ) {
|
||||
algorithm = cytoscape.elements().bfs('#' + root_id, function(){}, true);
|
||||
}
|
||||
else if( type === "dfs" ) {
|
||||
algorithm = cytoscape.elements().dfs('#' + root_id, function(){}, true);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
var selectNextElement = function() {
|
||||
if( i < bfs.path.length ) {
|
||||
if( i < algorithm.path.length ) {
|
||||
// Add css class for the selected edge
|
||||
bfs.path[i].addClass('bfspath');
|
||||
algorithm.path[i].addClass('searchpath');
|
||||
i++;
|
||||
setTimeout(selectNextElement, timeOut);
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -861,6 +861,17 @@ define(function() { return /******/ (function(modules) { // webpackBootstrap
|
||||
data : [ { label : 'Directed', value : 'triangle' },
|
||||
{ label : 'Undirected', value : '' } ]
|
||||
|
||||
},
|
||||
search_algorithm : {
|
||||
label : 'Graph search algorithm',
|
||||
help : 'Select a search algorithm.',
|
||||
type : 'select',
|
||||
display : 'radio',
|
||||
value : '',
|
||||
data : [ { label : 'Breadth First Search', value : 'bfs' },
|
||||
{ label : 'Depth First Search', value : 'dfs' },
|
||||
{ label : 'None', value : '' } ]
|
||||
|
||||
},
|
||||
min_zoom : {
|
||||
name : 'min_zoom',
|
||||
|
||||
File diff suppressed because one or more lines are too long
+11
@@ -41,6 +41,17 @@ define( [], function() {
|
||||
data : [ { label : 'Directed', value : 'triangle' },
|
||||
{ label : 'Undirected', value : '' } ]
|
||||
|
||||
},
|
||||
search_algorithm : {
|
||||
label : 'Graph search algorithm',
|
||||
help : 'Select a search algorithm.',
|
||||
type : 'select',
|
||||
display : 'radio',
|
||||
value : '',
|
||||
data : [ { label : 'Breadth First Search', value : 'bfs' },
|
||||
{ label : 'Depth First Search', value : 'dfs' },
|
||||
{ label : 'None', value : '' } ]
|
||||
|
||||
},
|
||||
min_zoom : {
|
||||
name : 'min_zoom',
|
||||
|
||||
+19
-10
@@ -48,9 +48,9 @@ define( [ 'utilities/utils', 'utilities/sifjson', 'plugins/cytoscape/cytoscape'
|
||||
}
|
||||
},
|
||||
{
|
||||
selector: '.bfspath',
|
||||
selector: '.searchpath',
|
||||
style: {
|
||||
'background-color': '#336699', // #61bffc
|
||||
'background-color': '#336699',
|
||||
'line-color': '#336699',
|
||||
'target-arrow-color': '#336699',
|
||||
'transition-property': 'background-color, line-color, target-arrow-color',
|
||||
@@ -62,9 +62,10 @@ define( [ 'utilities/utils', 'utilities/sifjson', 'plugins/cytoscape/cytoscape'
|
||||
|
||||
// Register tap event on graph nodes
|
||||
// Right now on tapping on any node, BFS starts from that node
|
||||
cytoscape.$('node').on('tap', function( e ) {
|
||||
var ele = e.cyTarget;
|
||||
self.run_bfs(cytoscape, ele.id());
|
||||
cytoscape.$( 'node' ).on('tap', function( e ) {
|
||||
var ele = e.cyTarget,
|
||||
search_algorithm = settings.get( 'search_algorithm' );
|
||||
self.run_search_algorithm(cytoscape, ele.id(), search_algorithm);
|
||||
});
|
||||
|
||||
chart.state( 'ok', 'Chart drawn.' );
|
||||
@@ -81,13 +82,21 @@ define( [ 'utilities/utils', 'utilities/sifjson', 'plugins/cytoscape/cytoscape'
|
||||
}
|
||||
});
|
||||
},
|
||||
run_bfs: function( cytoscape, root_id ) {
|
||||
var bfs = cytoscape.elements().bfs('#' + root_id, function(){}, true);
|
||||
var i = 0, timeOut = 1500;
|
||||
run_search_algorithm: function( cytoscape, root_id, type ) {
|
||||
var algorithm = "", i = 0, timeOut = 1500;
|
||||
if( type === "bfs" ) {
|
||||
algorithm = cytoscape.elements().bfs('#' + root_id, function(){}, true);
|
||||
}
|
||||
else if( type === "dfs" ) {
|
||||
algorithm = cytoscape.elements().dfs('#' + root_id, function(){}, true);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
var selectNextElement = function() {
|
||||
if( i < bfs.path.length ) {
|
||||
if( i < algorithm.path.length ) {
|
||||
// Add css class for the selected edge
|
||||
bfs.path[i].addClass('bfspath');
|
||||
algorithm.path[i].addClass('searchpath');
|
||||
i++;
|
||||
setTimeout(selectNextElement, timeOut);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user