- Notifications
You must be signed in to change notification settings - Fork 44
Implement closeness centrality algorithm #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a777aeb
to c0beafd
Compare Codecov Report
@@ Coverage Diff @@ ## master #104 +/- ## ============================================ - Coverage 87.50% 87.35% -0.16% - Complexity 2933 2988 +55 ============================================ Files 308 314 +6 Lines 10999 11195 +196 Branches 941 964 +23 ============================================ + Hits 9625 9779 +154 - Misses 929 957 +28 - Partials 445 459 +14
Continue to review full report at Codecov.
|
...in/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java Outdated Show resolved Hide resolved
...in/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java Outdated Show resolved Hide resolved
...in/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java Outdated Show resolved Hide resolved
computer-core/src/main/java/com/baidu/hugegraph/computer/core/graph/BuiltinGraphFactory.java Outdated Show resolved Hide resolved
...in/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java Outdated Show resolved Hide resolved
...in/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java Outdated Show resolved Hide resolved
...in/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java Outdated Show resolved Hide resolved
...in/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java Outdated Show resolved Hide resolved
for (int i = 0; i < size; i++) { | ||
Id id = this.graphFactory.createId(); | ||
id.read(in); | ||
Value<?> value = this.graphFactory.createValue(ValueType.DOUBLE); | ||
value.read(in); | ||
this.map.put(id, (DoubleValue) value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call map.read(in)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this map is HashMap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let ClosenessValue extend MapValue, or just use MapValue class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use MapValue
...rc/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessValue.java Outdated Show resolved Hide resolved
...om/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityLogOutput.java Outdated Show resolved Hide resolved
...a/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityOutput.java Outdated Show resolved Hide resolved
...a/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityOutput.java Outdated Show resolved Hide resolved
...main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java Outdated Show resolved Hide resolved
computer-test/src/main/java/com/baidu/hugegraph/computer/suite/unit/UnitTestBase.java Outdated Show resolved Hide resolved
353e56a
to e6be433
Compare } | ||
| ||
@Override | ||
public Object object() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to value
* until any queue is available | ||
*/ | ||
if (emptyQueueCount >= channelCount) { | ||
LOG.info("The send executor was blocked " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use debug level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will lead too many print info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will not lead too many print info?
* until any client is available | ||
*/ | ||
if (busyClientCount >= channelCount) { | ||
LOG.info("The send executor was blocked " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will lead too many print info
computer-core/src/main/java/com/baidu/hugegraph/computer/core/graph/value/MapValue.java Outdated Show resolved Hide resolved
...a/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityOutput.java Outdated Show resolved Hide resolved
MapValue<DoubleValue> localValue = vertex.value(); | ||
// Cumulative distance | ||
double centrality = 0; | ||
for (Map.Entry<Id, DoubleValue> entry : localValue.entrySet()) { | ||
centrality += 1.0D / entry.getValue().value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to MapValue.string()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What mean? Move the for-loop logic into string() method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean try to let ClosenessCentralityValue extends MapValue, move this block to ClosenessCentralityValue.value()/string(), and delete ClosenessCentralityLogOutput since LimitedLogOutput can log through ClosenessCentralityValue.string()
* until any queue is available | ||
*/ | ||
if (emptyQueueCount >= channelCount) { | ||
LOG.info("The send executor was blocked " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will not lead too many print info?
.put("F", 1.45) | ||
.build(); | ||
| ||
public Vertex constructHugeVertex( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override value() method instead
.put("F", 3.333333333333333) | ||
.build(); | ||
| ||
public Vertex constructHugeVertex( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
...main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java Outdated Show resolved Hide resolved
MapValue<DoubleValue> localValue = vertex.value(); | ||
// Cumulative distance | ||
double centrality = 0; | ||
for (Map.Entry<Id, DoubleValue> entry : localValue.entrySet()) { | ||
centrality += 1.0D / entry.getValue().value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean try to let ClosenessCentralityValue extends MapValue, move this block to ClosenessCentralityValue.value()/string(), and delete ClosenessCentralityLogOutput since LimitedLogOutput can log through ClosenessCentralityValue.string()
b712b05
to 92d9c53
Compare
No description provided.