Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tianyazhichiC
algorithm-visualizer
提交
c286e59d
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,发现更多精彩内容 >>
提交
c286e59d
编写于
5月 26, 2016
作者:
J
Jason Park
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove global vars
上级
a58a553c
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
521 addition
and
505 deletion
+521
-505
index.html
index.html
+1
-1
js/module/array2d.js
js/module/array2d.js
+6
-6
js/module/directed_graph.js
js/module/directed_graph.js
+3
-3
js/module/log_tracer.js
js/module/log_tracer.js
+1
-1
js/module/tracer.js
js/module/tracer.js
+7
-6
js/module/weighted_directed_graph.js
js/module/weighted_directed_graph.js
+6
-6
js/script.js
js/script.js
+480
-481
js/tracer_manager.js
js/tracer_manager.js
+17
-1
未找到文件。
index.html
浏览文件 @
c286e59d
...
...
@@ -111,7 +111,7 @@
<script
src=
"js/sigma/plugins/sigma.plugins.dragNodes.min.js"
></script>
<script
src=
"js/ace/ace.js"
></script>
<script
src=
"js/ace/ext-language_tools.js"
></script>
<script
src=
"js/
module/
tracer_manager.js"
></script>
<script
src=
"js/tracer_manager.js"
></script>
<script
src=
"js/module/tracer.js"
></script>
<script
src=
"js/module/log_tracer.js"
></script>
<script
src=
"js/module/array2d.js"
></script>
...
...
js/module/array2d.js
浏览文件 @
c286e59d
...
...
@@ -13,7 +13,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
this
.
$container
.
append
(
this
.
$table
);
},
_notify
:
function
(
x
,
y
,
v
)
{
tm
.
pushStep
(
this
.
capsule
,
{
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
notify
'
,
x
:
x
,
y
:
y
,
...
...
@@ -22,7 +22,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
return
this
;
},
_denotify
:
function
(
x
,
y
)
{
tm
.
pushStep
(
this
.
capsule
,
{
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
denotify
'
,
x
:
x
,
y
:
y
...
...
@@ -93,14 +93,14 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
type
:
type
};
$
.
extend
(
step
,
coord
);
tm
.
pushStep
(
this
.
capsule
,
step
);
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
step
);
},
processStep
:
function
(
step
,
options
)
{
switch
(
step
.
type
)
{
case
'
notify
'
:
if
(
step
.
v
)
{
var
$row
=
this
.
$table
.
find
(
'
.mtbl-row
'
).
eq
(
step
.
x
);
$row
.
find
(
'
.mtbl-cell
'
).
eq
(
step
.
y
).
text
(
refineNumber
(
step
.
v
));
$row
.
find
(
'
.mtbl-cell
'
).
eq
(
step
.
y
).
text
(
TracerUtil
.
refineNumber
(
step
.
v
));
}
case
'
denotify
'
:
case
'
select
'
:
...
...
@@ -130,7 +130,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
if
(
Tracer
.
prototype
.
setData
.
apply
(
this
,
arguments
))
{
this
.
$table
.
find
(
'
.mtbl-row
'
).
each
(
function
(
i
)
{
$
(
this
).
children
().
each
(
function
(
j
)
{
$
(
this
).
text
(
refineNumber
(
D
[
i
][
j
]));
$
(
this
).
text
(
TracerUtil
.
refineNumber
(
D
[
i
][
j
]));
});
});
return
true
;
...
...
@@ -143,7 +143,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
for
(
var
j
=
0
;
j
<
D
[
i
].
length
;
j
++
)
{
var
$cell
=
$
(
'
<div class="mtbl-cell">
'
)
.
css
(
this
.
getCellCss
())
.
text
(
refineNumber
(
D
[
i
][
j
]));
.
text
(
TracerUtil
.
refineNumber
(
D
[
i
][
j
]));
$row
.
append
(
$cell
);
}
}
...
...
js/module/directed_graph.js
浏览文件 @
c286e59d
...
...
@@ -46,15 +46,15 @@ DirectedGraphTracer.prototype = $.extend(true, Object.create(Tracer.prototype),
this
.
graph
=
this
.
capsule
.
graph
=
this
.
s
.
graph
;
},
_setTreeData
:
function
(
G
,
root
)
{
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
setTreeData
'
,
arguments
:
arguments
});
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
setTreeData
'
,
arguments
:
arguments
});
return
this
;
},
_visit
:
function
(
target
,
source
)
{
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
visit
'
,
target
:
target
,
source
:
source
});
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
visit
'
,
target
:
target
,
source
:
source
});
return
this
;
},
_leave
:
function
(
target
,
source
)
{
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
leave
'
,
target
:
target
,
source
:
source
});
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
leave
'
,
target
:
target
,
source
:
source
});
return
this
;
},
processStep
:
function
(
step
,
options
)
{
...
...
js/module/log_tracer.js
浏览文件 @
c286e59d
...
...
@@ -13,7 +13,7 @@ LogTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
this
.
$container
.
append
(
this
.
$wrapper
);
},
_print
:
function
(
msg
)
{
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
print
'
,
msg
:
msg
});
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
print
'
,
msg
:
msg
});
return
this
;
},
processStep
:
function
(
step
,
options
)
{
...
...
js/module/tracer.js
浏览文件 @
c286e59d
function
Tracer
(
name
)
{
this
.
module
=
this
.
constructor
;
this
.
capsule
=
tm
.
allocate
(
this
);
this
.
capsule
=
t
his
.
t
m
.
allocate
(
this
);
$
.
extend
(
this
,
this
.
capsule
);
this
.
setName
(
name
);
return
this
.
new
;
...
...
@@ -8,23 +8,24 @@ function Tracer(name) {
Tracer
.
prototype
=
{
constructor
:
Tracer
,
tm
:
null
,
_setData
:
function
()
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
setData
'
,
args
:
toJSON
(
args
)});
t
his
.
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
setData
'
,
args
:
TracerUtil
.
toJSON
(
args
)});
return
this
;
},
_clear
:
function
()
{
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
clear
'
});
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
clear
'
});
return
this
;
},
_wait
:
function
()
{
tm
.
newStep
();
t
his
.
t
m
.
newStep
();
return
this
;
},
processStep
:
function
(
step
,
options
)
{
switch
(
step
.
type
)
{
case
'
setData
'
:
this
.
setData
.
apply
(
this
,
fromJSON
(
step
.
args
));
this
.
setData
.
apply
(
this
,
TracerUtil
.
fromJSON
(
step
.
args
));
break
;
case
'
clear
'
:
this
.
clear
();
...
...
@@ -42,7 +43,7 @@ Tracer.prototype = {
$name
.
text
(
name
||
this
.
defaultName
);
},
setData
:
function
()
{
var
data
=
toJSON
(
arguments
);
var
data
=
TracerUtil
.
toJSON
(
arguments
);
if
(
!
this
.
new
&&
this
.
lastData
==
data
)
return
true
;
this
.
new
=
this
.
capsule
.
new
=
false
;
this
.
lastData
=
this
.
capsule
.
lastData
=
data
;
...
...
js/module/weighted_directed_graph.js
浏览文件 @
c286e59d
...
...
@@ -30,22 +30,22 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
});
},
_weight
:
function
(
target
,
weight
)
{
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
weight
'
,
target
:
target
,
weight
:
weight
});
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
weight
'
,
target
:
target
,
weight
:
weight
});
return
this
;
},
_visit
:
function
(
target
,
source
,
weight
)
{
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
visit
'
,
target
:
target
,
source
:
source
,
weight
:
weight
});
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
visit
'
,
target
:
target
,
source
:
source
,
weight
:
weight
});
return
this
;
},
_leave
:
function
(
target
,
source
,
weight
)
{
tm
.
pushStep
(
this
.
capsule
,
{
type
:
'
leave
'
,
target
:
target
,
source
:
source
,
weight
:
weight
});
t
his
.
t
m
.
pushStep
(
this
.
capsule
,
{
type
:
'
leave
'
,
target
:
target
,
source
:
source
,
weight
:
weight
});
return
this
;
},
processStep
:
function
(
step
,
options
)
{
switch
(
step
.
type
)
{
case
'
weight
'
:
var
targetNode
=
this
.
graph
.
nodes
(
this
.
n
(
step
.
target
));
if
(
step
.
weight
!==
undefined
)
targetNode
.
weight
=
refineNumber
(
step
.
weight
);
if
(
step
.
weight
!==
undefined
)
targetNode
.
weight
=
TracerUtil
.
refineNumber
(
step
.
weight
);
break
;
case
'
visit
'
:
case
'
leave
'
:
...
...
@@ -53,7 +53,7 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
var
targetNode
=
this
.
graph
.
nodes
(
this
.
n
(
step
.
target
));
var
color
=
visit
?
this
.
color
.
visited
:
this
.
color
.
left
;
targetNode
.
color
=
color
;
if
(
step
.
weight
!==
undefined
)
targetNode
.
weight
=
refineNumber
(
step
.
weight
);
if
(
step
.
weight
!==
undefined
)
targetNode
.
weight
=
TracerUtil
.
refineNumber
(
step
.
weight
);
if
(
step
.
source
!==
undefined
)
{
var
edgeId
=
this
.
e
(
step
.
source
,
step
.
target
);
var
edge
=
this
.
graph
.
edges
(
edgeId
);
...
...
@@ -97,7 +97,7 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
target
:
this
.
n
(
j
),
color
:
this
.
color
.
default
,
size
:
1
,
weight
:
refineNumber
(
G
[
i
][
j
])
weight
:
TracerUtil
.
refineNumber
(
G
[
i
][
j
])
});
}
}
...
...
js/script.js
浏览文件 @
c286e59d
此差异已折叠。
点击以展开。
js/
module/
tracer_manager.js
→
js/tracer_manager.js
浏览文件 @
c286e59d
...
...
@@ -10,7 +10,7 @@ var TracerManager = function () {
TracerManager
.
prototype
=
{
add
:
function
(
tracer
)
{
var
$container
=
$
(
'
<section class="module_wrapper">
'
);
$
module_container
.
append
(
$container
);
$
(
'
.module_container
'
)
.
append
(
$container
);
var
capsule
=
{
module
:
tracer
.
module
,
tracer
:
tracer
,
...
...
@@ -176,4 +176,20 @@ TracerManager.prototype = {
});
return
selectedCapsule
.
tracer
;
}
};
var
TracerUtil
=
{
toJSON
:
function
(
obj
)
{
return
JSON
.
stringify
(
obj
,
function
(
key
,
value
)
{
return
value
===
Infinity
?
"
Infinity
"
:
value
;
});
},
fromJSON
:
function
(
obj
)
{
return
JSON
.
parse
(
obj
,
function
(
key
,
value
)
{
return
value
===
"
Infinity
"
?
Infinity
:
value
;
});
},
refineNumber
:
function
(
number
)
{
return
number
===
Infinity
?
'
∞
'
:
number
;
}
};
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录