Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sanbo_xyz
Gephi
比较版本
9c2ec9e2bd2760e1728721cfa8ef77481678dc6f...4b9be0f985d5a96209d97456689e3fbe0291da25
G
Gephi
项目概览
sanbo_xyz
/
Gephi
9 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gephi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
源分支
4b9be0f985d5a96209d97456689e3fbe0291da25
选择Git版本
...
目标分支
9c2ec9e2bd2760e1728721cfa8ef77481678dc6f
选择Git版本
比较
Commits (2)
https://gitcode.net/loovejava/gephi/-/commit/c877d9ace23a1f5f8eb36a002d9dce40e439ad0f
Fix #2783 dynamic edge weight for slice
2023-03-25T21:49:38+01:00
Mathieu Bastian
mathieu.bastian@gmail.com
https://gitcode.net/loovejava/gephi/-/commit/4b9be0f985d5a96209d97456689e3fbe0291da25
Add processor tests
2023-03-25T22:01:38+01:00
Mathieu Bastian
mathieu.bastian@gmail.com
隐藏空白更改
内联
并排
Showing
11 changed file
with
311 addition
and
1 deletion
+311
-1
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ColumnDraftImpl.java
...main/java/org/gephi/io/importer/impl/ColumnDraftImpl.java
+5
-0
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/EdgeDraftImpl.java
...c/main/java/org/gephi/io/importer/impl/EdgeDraftImpl.java
+12
-0
modules/ImportPlugin/pom.xml
modules/ImportPlugin/pom.xml
+6
-0
modules/ImportPlugin/src/test/java/org/gephi/io/importer/plugin/file/GEXFTest.java
...test/java/org/gephi/io/importer/plugin/file/GEXFTest.java
+35
-0
modules/ImportPlugin/src/test/java/org/gephi/io/importer/plugin/file/Utils.java
...rc/test/java/org/gephi/io/importer/plugin/file/Utils.java
+5
-0
modules/ImportPlugin/src/test/java/org/gephi/io/processor/plugin/DefaultProcessorTest.java
...a/org/gephi/io/processor/plugin/DefaultProcessorTest.java
+1
-1
modules/ImportPlugin/src/test/java/org/gephi/io/processor/plugin/DynamicEdgeWeightTest.java
.../org/gephi/io/processor/plugin/DynamicEdgeWeightTest.java
+69
-0
modules/ImportPlugin/src/test/java/org/gephi/io/processor/plugin/EdgeWeightTest.java
...st/java/org/gephi/io/processor/plugin/EdgeWeightTest.java
+107
-0
modules/ImportPlugin/src/test/java/org/gephi/io/processor/plugin/Utils.java
...in/src/test/java/org/gephi/io/processor/plugin/Utils.java
+29
-0
modules/ImportPlugin/src/test/resources/org/gephi/io/importer/plugin/file/gexf/dynamicedgeweight.gexf
...gephi/io/importer/plugin/file/gexf/dynamicedgeweight.gexf
+20
-0
modules/ImportPlugin/src/test/resources/org/gephi/io/importer/plugin/file/gexf/slice.gexf
...sources/org/gephi/io/importer/plugin/file/gexf/slice.gexf
+22
-0
未找到文件。
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ColumnDraftImpl.java
浏览文件 @
4b9be0f9
...
...
@@ -141,4 +141,9 @@ public class ColumnDraftImpl implements ColumnDraft {
public
boolean
isDynamic
()
{
return
dynamic
;
}
@Override
public
String
toString
()
{
return
title
+
" ("
+
typeClass
.
toString
()
+
")"
;
}
}
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/EdgeDraftImpl.java
浏览文件 @
4b9be0f9
...
...
@@ -92,6 +92,18 @@ public class EdgeDraftImpl extends ElementDraftImpl implements EdgeDraft {
//SETTERS
@Override
public
void
setWeight
(
double
weight
)
{
if
(
getGraphInterval
()
!=
null
||
getGraphTimestamp
()
!=
null
)
{
// Slice mode
ColumnDraft
draftColumn
=
container
.
getEdgeColumn
(
"weight"
);
if
(
draftColumn
!=
null
&&
draftColumn
.
isDynamic
())
{
if
(
getGraphInterval
()
!=
null
)
{
setValue
(
"weight"
,
weight
,
getGraphInterval
().
getLow
(),
getGraphInterval
().
getHigh
());
}
else
{
setValue
(
"weight"
,
weight
,
getGraphTimestamp
());
}
return
;
}
}
this
.
weight
=
weight
;
}
...
...
modules/ImportPlugin/pom.xml
浏览文件 @
4b9be0f9
...
...
@@ -77,6 +77,12 @@
<artifactId>
org-netbeans-modules-masterfs
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.gephi
</groupId>
<artifactId>
graph-api
</artifactId>
<scope>
test
</scope>
<type>
test-jar
</type>
</dependency>
<dependency>
<groupId>
org.gephi
</groupId>
<artifactId>
io-exporter-plugin
</artifactId>
...
...
modules/ImportPlugin/src/test/java/org/gephi/io/importer/plugin/file/GEXFTest.java
浏览文件 @
4b9be0f9
package
org.gephi.io.importer.plugin.file
;
import
org.gephi.graph.api.AttributeUtils
;
import
org.gephi.graph.api.types.TimestampDoubleMap
;
import
org.gephi.graph.api.types.TimestampIntegerMap
;
import
org.gephi.io.importer.api.Container
;
import
org.gephi.io.importer.api.EdgeDraft
;
import
org.gephi.io.importer.api.MetadataDraft
;
...
...
@@ -84,4 +86,37 @@ public class GEXFTest {
Assert
.
assertEquals
(
"TITLE"
,
meta
.
getTitle
());
Assert
.
assertEquals
(
"DESCRIPTION"
,
meta
.
getDescription
());
}
@Test
public
void
testDynamicWeight
()
{
ImporterGEXF
importer
=
new
ImporterGEXF
();
importer
.
setReader
(
Utils
.
getReader
(
"gexf/dynamicedgeweight.gexf"
));
Container
container
=
new
ImportContainerImpl
();
importer
.
execute
(
container
.
getLoader
());
EdgeDraft
edge
=
Utils
.
getEdge
(
container
,
"0"
);
Assert
.
assertEquals
(
new
TimestampDoubleMap
(
new
double
[]
{
2004
,
2005
},
new
double
[]
{
1
,
2
}),
edge
.
getValue
(
"weight"
));
}
@Test
public
void
testSlice
()
{
ImporterGEXF
importer
=
new
ImporterGEXF
();
importer
.
setReader
(
Utils
.
getReader
(
"gexf/slice.gexf"
));
Container
container
=
new
ImportContainerImpl
();
importer
.
execute
(
container
.
getLoader
());
Assert
.
assertEquals
(
2007
,
container
.
getUnloader
().
getTimestamp
(),
0.0
);
Assert
.
assertTrue
(
container
.
getUnloader
().
getNodeColumn
(
"price"
).
isDynamic
());
Assert
.
assertTrue
(
container
.
getUnloader
().
getEdgeColumn
(
"weight"
).
isDynamic
());
NodeDraft
node
=
Utils
.
getNode
(
container
,
"1"
);
Assert
.
assertEquals
(
new
TimestampIntegerMap
(
new
double
[]
{
2007
},
new
int
[]
{
12
}),
node
.
getValue
(
"price"
));
EdgeDraft
edge
=
Utils
.
getEdge
(
container
,
"0"
);
Assert
.
assertEquals
(
new
TimestampDoubleMap
(
new
double
[]
{
2007
},
new
double
[]
{
2
}),
edge
.
getValue
(
"weight"
));
}
}
modules/ImportPlugin/src/test/java/org/gephi/io/importer/plugin/file/Utils.java
浏览文件 @
4b9be0f9
...
...
@@ -39,6 +39,11 @@ public class Utils {
return
Arrays
.
stream
(
nodes
).
filter
(
n
->
n
.
getId
().
equals
(
id
)).
findFirst
().
orElse
(
null
);
}
public
static
EdgeDraft
getEdge
(
Container
container
,
String
id
)
{
EdgeDraft
[]
edges
=
toEdgesArray
(
container
);
return
Arrays
.
stream
(
edges
).
filter
(
n
->
n
.
getId
().
equals
(
id
)).
findFirst
().
orElse
(
null
);
}
public
static
EdgeDraft
[]
toEdgesArray
(
Container
container
)
{
List
<
EdgeDraft
>
result
=
new
ArrayList
<>();
container
.
getUnloader
().
getEdges
().
iterator
().
forEachRemaining
(
result:
:
add
);
...
...
modules/ImportPlugin/src/test/java/org/gephi/io/
importe
r/plugin/DefaultProcessorTest.java
→
modules/ImportPlugin/src/test/java/org/gephi/io/
processo
r/plugin/DefaultProcessorTest.java
浏览文件 @
4b9be0f9
package
org.gephi.io.
importe
r.plugin
;
package
org.gephi.io.
processo
r.plugin
;
import
org.gephi.graph.api.GraphModel
;
import
org.gephi.graph.api.Node
;
...
...
modules/ImportPlugin/src/test/java/org/gephi/io/processor/plugin/DynamicEdgeWeightTest.java
0 → 100644
浏览文件 @
4b9be0f9
package
org.gephi.io.processor.plugin
;
import
java.util.Collections
;
import
org.gephi.graph.GraphGenerator
;
import
org.gephi.graph.api.Configuration
;
import
org.gephi.graph.api.Edge
;
import
org.gephi.graph.api.TimeRepresentation
;
import
org.gephi.graph.api.types.TimestampDoubleMap
;
import
org.gephi.io.importer.impl.EdgeDraftImpl
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
public
class
DynamicEdgeWeightTest
{
private
Utils
.
TestProcessor
processor
;
private
EdgeDraftImpl
edgeDraft
;
private
Edge
edge
;
@Before
public
void
setUp
()
{
Configuration
configuration
=
new
Configuration
();
configuration
.
setEdgeWeightType
(
TimestampDoubleMap
.
class
);
configuration
.
setTimeRepresentation
(
TimeRepresentation
.
TIMESTAMP
);
processor
=
new
Utils
.
TestProcessor
(
GraphGenerator
.
build
(
configuration
).
generateTinyGraph
().
getGraphModel
()
);
edgeDraft
=
new
EdgeDraftImpl
(
processor
.
getContainer
(),
GraphGenerator
.
FIRST_EDGE
);
processor
.
getContainer
().
setTimeRepresentation
(
TimeRepresentation
.
TIMESTAMP
);
edge
=
processor
.
graphModel
.
getGraph
().
getEdge
(
GraphGenerator
.
FIRST_EDGE
);
}
@Test
public
void
testNewEdge
()
{
processor
.
getContainer
().
addEdgeColumn
(
"weight"
,
Double
.
class
,
true
);
edgeDraft
.
setValue
(
"weight"
,
new
TimestampDoubleMap
(
new
double
[]
{
2.0
},
new
double
[]
{
4.0
}));
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
true
);
Assert
.
assertEquals
(
Collections
.
EMPTY_LIST
,
processor
.
getReport
().
getIssuesList
(
100
));
Assert
.
assertEquals
(
4.0
,
edge
.
getWeight
(
2.0
),
0.0
);
}
@Test
public
void
testMergeWeight
()
{
edge
.
setWeight
(
5.0
,
1.0
);
processor
.
getContainer
().
addEdgeColumn
(
"weight"
,
Double
.
class
,
true
);
edgeDraft
.
setValue
(
"weight"
,
new
TimestampDoubleMap
(
new
double
[]
{
2.0
},
new
double
[]
{
4.0
}));
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
(
Collections
.
EMPTY_LIST
,
processor
.
getReport
().
getIssuesList
(
100
));
Assert
.
assertEquals
(
4.0
,
edge
.
getWeight
(
2.0
),
0.0
);
Assert
.
assertEquals
(
5.0
,
edge
.
getWeight
(
1.0
),
0.0
);
}
@Test
public
void
testPreserveEdgeWeight
()
{
processor
.
getContainer
().
addEdgeColumn
(
"weight"
,
Double
.
class
,
true
);
edge
.
setWeight
(
5.0
,
1.0
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
(
Collections
.
EMPTY_LIST
,
processor
.
getReport
().
getIssuesList
(
100
));
Assert
.
assertEquals
(
5.0
,
edge
.
getWeight
(
1.0
),
0.0
);
}
}
modules/ImportPlugin/src/test/java/org/gephi/io/processor/plugin/EdgeWeightTest.java
0 → 100644
浏览文件 @
4b9be0f9
package
org.gephi.io.processor.plugin
;
import
org.gephi.graph.GraphGenerator
;
import
org.gephi.graph.api.Edge
;
import
org.gephi.io.importer.api.EdgeMergeStrategy
;
import
org.gephi.io.importer.impl.EdgeDraftImpl
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
public
class
EdgeWeightTest
{
private
Utils
.
TestProcessor
processor
;
private
EdgeDraftImpl
edgeDraft
;
private
Edge
edge
;
@Before
public
void
setUp
()
{
processor
=
new
Utils
.
TestProcessor
(
GraphGenerator
.
build
().
generateTinyGraph
().
getGraphModel
()
);
edgeDraft
=
new
EdgeDraftImpl
(
processor
.
getContainer
(),
GraphGenerator
.
FIRST_EDGE
);
edge
=
processor
.
graphModel
.
getGraph
().
getEdge
(
GraphGenerator
.
FIRST_EDGE
);
}
@Test
public
void
testSumMergeStrategy
()
{
edgeDraft
.
setWeight
(
42.0
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
(
edgeDraft
.
getWeight
()
+
1
,
edge
.
getWeight
(),
0.0
);
}
@Test
public
void
testFirstMergeStrategy
()
{
edgeDraft
.
setWeight
(
42.0
);
processor
.
getContainer
().
setEdgesMergeStrategy
(
EdgeMergeStrategy
.
FIRST
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
(
1
,
edge
.
getWeight
(),
0.0
);
}
@Test
public
void
testLastMergeStrategy
()
{
edgeDraft
.
setWeight
(
42.0
);
processor
.
getContainer
().
setEdgesMergeStrategy
(
EdgeMergeStrategy
.
LAST
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
(
edgeDraft
.
getWeight
(),
edge
.
getWeight
(),
0.0
);
}
@Test
public
void
testNoMergeStrategy
()
{
edgeDraft
.
setWeight
(
42.0
);
processor
.
getContainer
().
setEdgesMergeStrategy
(
EdgeMergeStrategy
.
NO_MERGE
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
(
1
,
edge
.
getWeight
(),
0.0
);
}
@Test
public
void
testAvgMergeStrategy
()
{
edgeDraft
.
setWeight
(
42.0
);
processor
.
getContainer
().
setEdgesMergeStrategy
(
EdgeMergeStrategy
.
AVG
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
((
edgeDraft
.
getWeight
()
+
1
)
/
2
,
edge
.
getWeight
(),
0.0
);
}
@Test
public
void
testAvgMergeStrategyWithThree
()
{
processor
.
getContainer
().
setEdgesMergeStrategy
(
EdgeMergeStrategy
.
AVG
);
edge
.
setWeight
(
4
);
edgeDraft
=
new
EdgeDraftImpl
(
processor
.
getContainer
(),
GraphGenerator
.
FIRST_EDGE
);
edgeDraft
.
setWeight
(
10.0
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
((
24.0
)
/
3
,
edge
.
getWeight
(),
0.0
);
}
@Test
public
void
testMinMergeStrategy
()
{
edgeDraft
.
setWeight
(
42.0
);
processor
.
getContainer
().
setEdgesMergeStrategy
(
EdgeMergeStrategy
.
MIN
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
(
1
,
edge
.
getWeight
(),
0.0
);
}
@Test
public
void
testMaxMergeStrategy
()
{
edgeDraft
.
setWeight
(
42.0
);
processor
.
getContainer
().
setEdgesMergeStrategy
(
EdgeMergeStrategy
.
MAX
);
processor
.
flushEdgeWeight
(
processor
.
getContainer
(),
edgeDraft
,
edge
,
false
);
Assert
.
assertEquals
(
edgeDraft
.
getWeight
(),
edge
.
getWeight
(),
0.0
);
}
}
modules/ImportPlugin/src/test/java/org/gephi/io/processor/plugin/Utils.java
0 → 100644
浏览文件 @
4b9be0f9
package
org.gephi.io.processor.plugin
;
import
org.gephi.graph.api.GraphModel
;
import
org.gephi.io.importer.impl.ImportContainerImpl
;
public
class
Utils
{
protected
static
class
TestProcessor
extends
AbstractProcessor
{
public
TestProcessor
(
GraphModel
graphModel
)
{
this
.
graphModel
=
graphModel
;
this
.
containers
=
new
ImportContainerImpl
[]
{
new
ImportContainerImpl
()};
}
public
ImportContainerImpl
getContainer
()
{
return
(
ImportContainerImpl
)
containers
[
0
];
}
@Override
public
void
process
()
{
}
@Override
public
String
getDisplayName
()
{
return
null
;
}
}
}
modules/ImportPlugin/src/test/resources/org/gephi/io/importer/plugin/file/gexf/dynamicedgeweight.gexf
0 → 100644
浏览文件 @
4b9be0f9
<?xml version="1.0" encoding="UTF-8"?>
<gexf
xmlns=
"http://www.gexf.net/1.3"
version=
"1.3"
>
<graph
mode=
"dynamic"
defaultedgetype=
"directed"
timeformat=
"double"
timerepresentation=
"timestamp"
>
<attributes
class=
"edge"
mode=
"dynamic"
>
<attribute
id=
"weight"
title=
"Weight"
type=
"double"
/>
</attributes>
<nodes>
<node
id=
"0"
label=
"Hello"
/>
<node
id=
"1"
label=
"Word"
/>
</nodes>
<edges>
<edge
id=
"0"
source=
"0"
target=
"1"
>
<attvalues>
<attvalue
for=
"weight"
value=
"1"
timestamp=
"2004"
/>
<attvalue
for=
"weight"
value=
"2"
timestamp=
"2005"
/>
</attvalues>
</edge>
</edges>
</graph>
</gexf>
\ No newline at end of file
modules/ImportPlugin/src/test/resources/org/gephi/io/importer/plugin/file/gexf/slice.gexf
0 → 100755
浏览文件 @
4b9be0f9
<?xml version="1.0" encoding="UTF-8"?>
<gexf
xmlns=
"http://www.gexf.net/1.3"
version=
"1.3"
>
<graph
mode=
"slice"
defaultedgetype=
"directed"
timerepresentation=
"timestamp"
timestamp=
"2007"
>
<attributes
class=
"node"
type=
"dynamic"
>
<attribute
id=
"price"
title=
"Price"
type=
"int"
/>
</attributes>
<attributes
class=
"edge"
type=
"dynamic"
>
<attribute
id=
"weight"
title=
"Weight"
type=
"double"
/>
</attributes>
<nodes>
<node
id=
"1"
label=
"Node 1"
>
<attvalue
for=
"price"
value=
"12"
/>
</node>
<node
id=
"2"
label=
"Node 2"
>
<attvalue
for=
"price"
value=
"8"
/>
</node>
</nodes>
<edges>
<edge
id =
"0"
source=
"1"
target=
"2"
weight=
"2"
/>
</edges>
</graph>
</gexf>
\ No newline at end of file