Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tianyazhichiC
algorithm-visualizer
提交
7d3f7561
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看板
提交
7d3f7561
编写于
5月 30, 2016
作者:
T
TornjV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add coordinate system tracer
上级
30503e10
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
381 addition
and
54 deletion
+381
-54
js/module/coordinate_system.js
js/module/coordinate_system.js
+156
-0
js/module/index.js
js/module/index.js
+7
-0
public/algorithm_visualizer.js
public/algorithm_visualizer.js
+214
-50
public/algorithm_visualizer.js.map
public/algorithm_visualizer.js.map
+1
-1
public/algorithm_visualizer.min.js
public/algorithm_visualizer.min.js
+2
-2
public/algorithm_visualizer.min.js.map
public/algorithm_visualizer.min.js.map
+1
-1
未找到文件。
js/module/coordinate_system.js
0 → 100644
浏览文件 @
7d3f7561
const
{
DirectedGraph
,
DirectedGraphTracer
}
=
require
(
'
./directed_graph
'
);
function
CoordinateSystemTracer
()
{
if
(
DirectedGraphTracer
.
apply
(
this
,
arguments
))
{
CoordinateSystemTracer
.
prototype
.
init
.
call
(
this
);
return
true
;
}
return
false
;
}
CoordinateSystemTracer
.
prototype
=
$
.
extend
(
true
,
Object
.
create
(
DirectedGraphTracer
.
prototype
),
{
constructor
:
CoordinateSystemTracer
,
init
:
function
()
{
var
tracer
=
this
;
this
.
s
.
settings
({
defaultEdgeType
:
'
def
'
,
funcEdgesDef
:
function
(
edge
,
source
,
target
,
context
,
settings
)
{
var
color
=
tracer
.
getColor
(
edge
,
source
,
target
,
settings
);
tracer
.
drawEdge
(
edge
,
source
,
target
,
color
,
context
,
settings
);
}
});
},
setData
:
function
(
C
)
{
if
(
Tracer
.
prototype
.
setData
.
apply
(
this
,
arguments
))
return
true
;
this
.
graph
.
clear
();
var
nodes
=
[];
var
edges
=
[];
for
(
var
i
=
0
;
i
<
C
.
length
;
i
++
)
nodes
.
push
({
id
:
this
.
n
(
i
),
x
:
C
[
i
][
0
],
y
:
C
[
i
][
1
],
label
:
''
+
i
,
size
:
1
,
color
:
this
.
color
.
default
});
this
.
graph
.
read
({
nodes
:
nodes
,
edges
:
edges
});
this
.
s
.
camera
.
goTo
({
x
:
0
,
y
:
0
,
angle
:
0
,
ratio
:
1
});
this
.
refresh
();
return
false
;
},
processStep
:
function
(
step
,
options
)
{
switch
(
step
.
type
)
{
case
'
visit
'
:
case
'
leave
'
:
var
visit
=
step
.
type
==
'
visit
'
;
var
targetNode
=
this
.
graph
.
nodes
(
this
.
n
(
step
.
target
));
var
color
=
visit
?
this
.
color
.
visited
:
this
.
color
.
left
;
targetNode
.
color
=
color
;
if
(
step
.
source
!==
undefined
)
{
var
edgeId
=
this
.
e
(
step
.
source
,
step
.
target
);
if
(
this
.
graph
.
edges
(
edgeId
))
{
var
edge
=
this
.
graph
.
edges
(
edgeId
);
edge
.
color
=
color
;
this
.
graph
.
dropEdge
(
edgeId
).
addEdge
(
edge
);
}
else
{
this
.
graph
.
addEdge
({
id
:
this
.
e
(
step
.
target
,
step
.
source
),
source
:
this
.
n
(
step
.
source
),
target
:
this
.
n
(
step
.
target
),
color
:
color
,
size
:
1
});
}
}
if
(
this
.
logTracer
)
{
var
source
=
step
.
source
;
if
(
source
===
undefined
)
source
=
''
;
this
.
logTracer
.
print
(
visit
?
source
+
'
->
'
+
step
.
target
:
source
+
'
<-
'
+
step
.
target
);
}
break
;
default
:
Tracer
.
prototype
.
processStep
.
call
(
this
,
step
,
options
);
}
},
e
:
function
(
v1
,
v2
)
{
if
(
v1
>
v2
)
{
var
temp
=
v1
;
v1
=
v2
;
v2
=
temp
;
}
return
'
e
'
+
v1
+
'
_
'
+
v2
;
},
drawOnHover
:
function
(
node
,
context
,
settings
,
next
)
{
var
tracer
=
this
;
context
.
setLineDash
([
5
,
5
]);
var
nodeIdx
=
node
.
id
.
substring
(
1
);
this
.
graph
.
edges
().
forEach
(
function
(
edge
)
{
var
ends
=
edge
.
id
.
substring
(
1
).
split
(
"
_
"
);
if
(
ends
[
0
]
==
nodeIdx
)
{
var
color
=
'
#0ff
'
;
var
source
=
node
;
var
target
=
tracer
.
graph
.
nodes
(
'
n
'
+
ends
[
1
]);
tracer
.
drawEdge
(
edge
,
source
,
target
,
color
,
context
,
settings
);
if
(
next
)
next
(
edge
,
source
,
target
,
color
,
context
,
settings
);
}
else
if
(
ends
[
1
]
==
nodeIdx
)
{
var
color
=
'
#0ff
'
;
var
source
=
tracer
.
graph
.
nodes
(
'
n
'
+
ends
[
0
]);
var
target
=
node
;
tracer
.
drawEdge
(
edge
,
source
,
target
,
color
,
context
,
settings
);
if
(
next
)
next
(
edge
,
source
,
target
,
color
,
context
,
settings
);
}
});
},
drawEdge
:
function
(
edge
,
source
,
target
,
color
,
context
,
settings
)
{
var
prefix
=
settings
(
'
prefix
'
)
||
''
,
size
=
edge
[
prefix
+
'
size
'
]
||
1
;
context
.
strokeStyle
=
color
;
context
.
lineWidth
=
size
;
context
.
beginPath
();
context
.
moveTo
(
source
[
prefix
+
'
x
'
],
source
[
prefix
+
'
y
'
]
);
context
.
lineTo
(
target
[
prefix
+
'
x
'
],
target
[
prefix
+
'
y
'
]
);
context
.
stroke
();
}
});
var
CoordinateSystem
=
{
random
:
function
(
N
,
min
,
max
)
{
if
(
!
N
)
N
=
7
;
if
(
!
min
)
min
=
1
;
if
(
!
max
)
max
=
10
;
var
C
=
new
Array
(
N
);
for
(
var
i
=
0
;
i
<
N
;
i
++
)
C
[
i
]
=
new
Array
(
2
);
for
(
var
i
=
0
;
i
<
N
;
i
++
)
for
(
var
j
=
0
;
j
<
C
[
i
].
length
;
j
++
)
C
[
i
][
j
]
=
(
Math
.
random
()
*
(
max
-
min
+
1
)
|
0
)
+
min
;
return
C
;
}
};
module
.
exports
=
{
CoordinateSystem
,
CoordinateSystemTracer
};
\ No newline at end of file
js/module/index.js
浏览文件 @
7d3f7561
...
...
@@ -15,6 +15,11 @@ const {
const
ChartTracer
=
require
(
'
./chart
'
);
const
{
CoordinateSystem
,
CoordinateSystemTracer
}
=
require
(
'
./coordinate_system
'
);
const
{
DirectedGraph
,
DirectedGraphTracer
...
...
@@ -41,6 +46,8 @@ module.exports = {
Array2D
,
Array2DTracer
,
ChartTracer
,
CoordinateSystem
,
CoordinateSystemTracer
,
DirectedGraph
,
DirectedGraphTracer
,
UndirectedGraph
,
...
...
public/algorithm_visualizer.js
浏览文件 @
7d3f7561
此差异已折叠。
点击以展开。
public/algorithm_visualizer.js.map
浏览文件 @
7d3f7561
此差异已折叠。
点击以展开。
public/algorithm_visualizer.min.js
浏览文件 @
7d3f7561
此差异已折叠。
点击以展开。
public/algorithm_visualizer.min.js.map
浏览文件 @
7d3f7561
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录