Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tianyazhichiC
algorithm-visualizer
提交
8f0f4be1
A
algorithm-visualizer
项目概览
tianyazhichiC
/
algorithm-visualizer
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
algorithm-visualizer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8f0f4be1
编写于
5月 22, 2016
作者:
J
Jason Park
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename Graph to DirectedGraph, and WeightedGraph to WeightedDirectedGraph
上级
29ed1f4c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
29 deletion
+29
-29
index.html
index.html
+2
-2
js/module/directed_graph.js
js/module/directed_graph.js
+14
-14
js/module/directed_weighted_graph.js
js/module/directed_weighted_graph.js
+13
-13
未找到文件。
index.html
浏览文件 @
8f0f4be1
...
...
@@ -108,8 +108,8 @@
<script
src=
"js/sigma/plugins/sigma.plugins.dragNodes.min.js"
></script>
<script
src=
"js/ace/ace.js"
></script>
<script
src=
"js/module/tracer.js"
></script>
<script
src=
"js/module/graph.js"
></script>
<script
src=
"js/module/weighted_graph.js"
></script>
<script
src=
"js/module/
directed_
graph.js"
></script>
<script
src=
"js/module/
directed_
weighted_graph.js"
></script>
<script
src=
"js/module/array2d.js"
></script>
<script
src=
"js/module/array1d.js"
></script>
<script
src=
"js/script.js"
></script>
...
...
js/module/graph.js
→
js/module/
directed_
graph.js
浏览文件 @
8f0f4be1
var
s
=
null
,
graph
=
null
,
sigmaCanvas
=
null
;
function
GraphTracer
(
module
)
{
if
(
Tracer
.
call
(
this
,
module
||
GraphTracer
))
{
function
Directed
GraphTracer
(
module
)
{
if
(
Tracer
.
call
(
this
,
module
||
Directed
GraphTracer
))
{
initGraph
();
return
true
;
}
return
false
;
}
GraphTracer
.
prototype
=
Object
.
create
(
Tracer
.
prototype
);
GraphTracer
.
prototype
.
constructor
=
GraphTracer
;
Directed
GraphTracer
.
prototype
=
Object
.
create
(
Tracer
.
prototype
);
DirectedGraphTracer
.
prototype
.
constructor
=
Directed
GraphTracer
;
// Override
GraphTracer
.
prototype
.
resize
=
function
()
{
Directed
GraphTracer
.
prototype
.
resize
=
function
()
{
Tracer
.
prototype
.
resize
.
call
(
this
);
this
.
refresh
();
};
// Override
GraphTracer
.
prototype
.
clear
=
function
()
{
Directed
GraphTracer
.
prototype
.
clear
=
function
()
{
Tracer
.
prototype
.
clear
.
call
(
this
);
clearGraphColor
();
};
var
Graph
=
{
var
Directed
Graph
=
{
random
:
function
(
N
,
ratio
)
{
if
(
!
N
)
N
=
5
;
if
(
!
ratio
)
ratio
=
.
3
;
...
...
@@ -41,7 +41,7 @@ var Graph = {
}
};
GraphTracer
.
prototype
.
_setTreeData
=
function
(
G
,
root
)
{
Directed
GraphTracer
.
prototype
.
_setTreeData
=
function
(
G
,
root
)
{
root
=
root
||
0
;
var
maxDepth
=
-
1
;
...
...
@@ -84,7 +84,7 @@ GraphTracer.prototype._setTreeData = function (G, root) {
};
// Override
GraphTracer
.
prototype
.
_setData
=
function
(
G
)
{
Directed
GraphTracer
.
prototype
.
_setData
=
function
(
G
)
{
if
(
Tracer
.
prototype
.
_setData
.
call
(
this
,
arguments
))
return
true
;
graph
.
clear
();
...
...
@@ -130,15 +130,15 @@ GraphTracer.prototype._setData = function (G) {
return
false
;
};
GraphTracer
.
prototype
.
_visit
=
function
(
target
,
source
)
{
Directed
GraphTracer
.
prototype
.
_visit
=
function
(
target
,
source
)
{
this
.
pushStep
({
type
:
'
visit
'
,
target
:
target
,
source
:
source
},
true
);
};
GraphTracer
.
prototype
.
_leave
=
function
(
target
,
source
)
{
Directed
GraphTracer
.
prototype
.
_leave
=
function
(
target
,
source
)
{
this
.
pushStep
({
type
:
'
leave
'
,
target
:
target
,
source
:
source
},
true
);
};
GraphTracer
.
prototype
.
processStep
=
function
(
step
,
options
)
{
Directed
GraphTracer
.
prototype
.
processStep
=
function
(
step
,
options
)
{
switch
(
step
.
type
)
{
case
'
visit
'
:
case
'
leave
'
:
...
...
@@ -160,14 +160,14 @@ GraphTracer.prototype.processStep = function (step, options) {
};
// Override
GraphTracer
.
prototype
.
refresh
=
function
()
{
Directed
GraphTracer
.
prototype
.
refresh
=
function
()
{
Tracer
.
prototype
.
refresh
.
call
(
this
);
s
.
refresh
();
};
// Override
GraphTracer
.
prototype
.
prevStep
=
function
()
{
Directed
GraphTracer
.
prototype
.
prevStep
=
function
()
{
this
.
clear
();
$
(
'
#tab_trace .wrapper
'
).
empty
();
var
finalIndex
=
this
.
traceIndex
-
1
;
...
...
js/module/weighted_graph.js
→
js/module/
directed_
weighted_graph.js
浏览文件 @
8f0f4be1
function
WeightedGraphTracer
(
module
)
{
if
(
GraphTracer
.
call
(
this
,
module
||
Weigh
tedGraphTracer
))
{
function
Weighted
Directed
GraphTracer
(
module
)
{
if
(
DirectedGraphTracer
.
call
(
this
,
module
||
WeightedDirec
tedGraphTracer
))
{
initWeightedGraph
();
return
true
;
}
return
false
;
}
Weighted
GraphTracer
.
prototype
=
Object
.
create
(
GraphTracer
.
prototype
);
Weighted
GraphTracer
.
prototype
.
constructor
=
Weigh
tedGraphTracer
;
Weighted
DirectedGraphTracer
.
prototype
=
Object
.
create
(
Directed
GraphTracer
.
prototype
);
Weighted
DirectedGraphTracer
.
prototype
.
constructor
=
WeightedDirec
tedGraphTracer
;
// Override
WeightedGraphTracer
.
prototype
.
clear
=
function
()
{
GraphTracer
.
prototype
.
clear
.
call
(
this
);
Weighted
Directed
GraphTracer
.
prototype
.
clear
=
function
()
{
Directed
GraphTracer
.
prototype
.
clear
.
call
(
this
);
clearWeights
();
};
var
WeightedGraph
=
{
var
Weighted
Directed
Graph
=
{
random
:
function
(
N
,
ratio
,
min
,
max
)
{
if
(
!
N
)
N
=
5
;
if
(
!
ratio
)
ratio
=
.
3
;
...
...
@@ -39,7 +39,7 @@ var WeightedGraph = {
};
// Override
WeightedGraphTracer
.
prototype
.
_setData
=
function
(
G
)
{
Weighted
Directed
GraphTracer
.
prototype
.
_setData
=
function
(
G
)
{
if
(
Tracer
.
prototype
.
_setData
.
call
(
this
,
arguments
))
return
true
;
graph
.
clear
();
...
...
@@ -87,20 +87,20 @@ WeightedGraphTracer.prototype._setData = function (G) {
return
false
;
};
GraphTracer
.
prototype
.
_weight
=
function
(
target
,
weight
,
delay
)
{
Directed
GraphTracer
.
prototype
.
_weight
=
function
(
target
,
weight
,
delay
)
{
this
.
pushStep
({
type
:
'
weight
'
,
target
:
target
,
weight
:
weight
},
delay
);
};
GraphTracer
.
prototype
.
_visit
=
function
(
target
,
source
,
weight
)
{
Directed
GraphTracer
.
prototype
.
_visit
=
function
(
target
,
source
,
weight
)
{
this
.
pushStep
({
type
:
'
visit
'
,
target
:
target
,
source
:
source
,
weight
:
weight
},
true
);
};
GraphTracer
.
prototype
.
_leave
=
function
(
target
,
source
,
weight
)
{
Directed
GraphTracer
.
prototype
.
_leave
=
function
(
target
,
source
,
weight
)
{
this
.
pushStep
({
type
:
'
leave
'
,
target
:
target
,
source
:
source
,
weight
:
weight
},
true
);
};
//Override
WeightedGraphTracer
.
prototype
.
processStep
=
function
(
step
,
options
)
{
Weighted
Directed
GraphTracer
.
prototype
.
processStep
=
function
(
step
,
options
)
{
switch
(
step
.
type
)
{
case
'
weight
'
:
var
targetNode
=
graph
.
nodes
(
n
(
step
.
target
));
...
...
@@ -124,7 +124,7 @@ WeightedGraphTracer.prototype.processStep = function (step, options) {
printTrace
(
visit
?
source
+
'
->
'
+
step
.
target
:
source
+
'
<-
'
+
step
.
target
);
break
;
default
:
GraphTracer
.
prototype
.
processStep
.
call
(
this
,
step
,
options
);
Directed
GraphTracer
.
prototype
.
processStep
.
call
(
this
,
step
,
options
);
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录