Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
API
Commits
6753a951
Commit
6753a951
authored
Feb 09, 2016
by
Roland Kluge
Browse files
Add docu
parent
a4cf1e38
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/common/graph/EdgeID.java
View file @
6753a951
...
...
@@ -49,16 +49,24 @@ public class EdgeID extends GraphElementID {
return
id
;
}
private
static
int
determineHashCode
(
String
str
)
{
if
(
str
.
matches
(
"\\d+->\\d+"
))
{
final
String
[]
segments
=
str
.
split
(
"->"
);
/**
* This method calculates the hash code for the given edge ID.
*
* If the ID has the specific format for directed edges (e.g., 12->541),
* then the hash code is calculated in a way that avoids hash collisions (at
* least for node counts up to 1e5).
*
* @param edgeId
* @return the hash code to be used
*/
private
static
int
determineHashCode
(
String
edgeId
)
{
if
(
edgeId
.
matches
(
"\\d+->\\d+"
))
{
final
String
[]
segments
=
edgeId
.
split
(
"->"
);
final
int
sourceId
=
Integer
.
parseInt
(
segments
[
0
]);
final
int
targetId
=
Integer
.
parseInt
(
segments
[
1
]);
return
sourceId
*
100000
+
targetId
;
}
else
{
return
str
.
hashCode
();
}
else
{
return
edgeId
.
hashCode
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment