Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MH-Tree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
disa
public
Hulls
MH-Tree
Commits
a1afa79d
There was an error fetching the commit references. Please try again later.
Verified
Commit
a1afa79d
authored
4 years ago
by
David Procházka
Browse files
Options
Downloads
Patches
Plain Diff
DEL: distance computation, unused contains method
parent
9531e93e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mhtree/InternalNode.java
+4
-8
4 additions, 8 deletions
src/mhtree/InternalNode.java
src/mhtree/LeafNode.java
+3
-10
3 additions, 10 deletions
src/mhtree/LeafNode.java
src/mhtree/Node.java
+8
-34
8 additions, 34 deletions
src/mhtree/Node.java
with
15 additions
and
52 deletions
src/mhtree/InternalNode.java
+
4
−
8
View file @
a1afa79d
...
@@ -22,7 +22,7 @@ public class InternalNode extends Node implements Serializable {
...
@@ -22,7 +22,7 @@ public class InternalNode extends Node implements Serializable {
children
=
new
HashSet
<>();
children
=
new
HashSet
<>();
}
}
public
void
addChildren
(
Se
t
<
Node
>
children
)
{
public
void
addChildren
(
Lis
t
<
Node
>
children
)
{
this
.
children
.
addAll
(
children
);
this
.
children
.
addAll
(
children
);
}
}
...
@@ -48,10 +48,6 @@ public class InternalNode extends Node implements Serializable {
...
@@ -48,10 +48,6 @@ public class InternalNode extends Node implements Serializable {
.
collect
(
Collectors
.
toSet
());
.
collect
(
Collectors
.
toSet
());
}
}
public
boolean
contains
(
LocalAbstractObject
object
)
{
return
children
.
stream
().
anyMatch
(
child
->
child
.
contains
(
object
));
}
public
int
getHeight
()
{
public
int
getHeight
()
{
return
children
.
stream
()
return
children
.
stream
()
.
mapToInt
(
Node:
:
getHeight
)
.
mapToInt
(
Node:
:
getHeight
)
...
@@ -59,12 +55,12 @@ public class InternalNode extends Node implements Serializable {
...
@@ -59,12 +55,12 @@ public class InternalNode extends Node implements Serializable {
.
getMax
()
+
1
;
.
getMax
()
+
1
;
}
}
public
Se
t
<
Node
>
getNodesOnLevel
(
int
level
)
{
public
Lis
t
<
Node
>
getNodesOnLevel
(
int
level
)
{
if
(
getLevel
()
==
level
)
return
Collections
.
singleton
(
this
);
if
(
getLevel
()
==
level
)
return
Collections
.
singleton
List
(
this
);
return
children
.
stream
()
return
children
.
stream
()
.
map
(
child
->
child
.
getNodesOnLevel
(
level
))
.
map
(
child
->
child
.
getNodesOnLevel
(
level
))
.
flatMap
(
Collection:
:
stream
)
.
flatMap
(
Collection:
:
stream
)
.
collect
(
Collectors
.
to
Se
t
());
.
collect
(
Collectors
.
to
Lis
t
());
}
}
}
}
This diff is collapsed.
Click to expand it.
src/mhtree/LeafNode.java
+
3
−
10
View file @
a1afa79d
...
@@ -9,6 +9,7 @@ import messif.objects.util.AbstractObjectIterator;
...
@@ -9,6 +9,7 @@ import messif.objects.util.AbstractObjectIterator;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
public
class
LeafNode
extends
Node
implements
Serializable
{
public
class
LeafNode
extends
Node
implements
Serializable
{
...
@@ -41,19 +42,11 @@ public class LeafNode extends Node implements Serializable {
...
@@ -41,19 +42,11 @@ public class LeafNode extends Node implements Serializable {
return
objects
;
return
objects
;
}
}
public
boolean
contains
(
LocalAbstractObject
object
)
{
for
(
AbstractObjectIterator
<
LocalAbstractObject
>
it
=
bucket
.
getAllObjects
();
it
.
hasNext
();
)
if
(
object
==
it
.
next
())
return
true
;
return
false
;
}
public
int
getHeight
()
{
public
int
getHeight
()
{
return
0
;
return
0
;
}
}
public
Se
t
<
Node
>
getNodesOnLevel
(
int
level
)
{
public
Lis
t
<
Node
>
getNodesOnLevel
(
int
level
)
{
return
Collections
.
singleton
(
this
);
return
Collections
.
singleton
List
(
this
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/mhtree/Node.java
+
8
−
34
View file @
a1afa79d
...
@@ -18,9 +18,8 @@ public abstract class Node implements Serializable {
...
@@ -18,9 +18,8 @@ public abstract class Node implements Serializable {
* Serialization ID
* Serialization ID
*/
*/
private
static
final
long
serialVersionUID
=
420L
;
private
static
final
long
serialVersionUID
=
420L
;
private
final
ObjectToNodeDistance
objectToNodeDistance
;
protected
final
InsertType
insertType
;
protected
final
InsertType
insertType
;
private
final
ObjectToNodeDistance
objectToNodeDistance
;
protected
HullOptimizedRepresentationV3
hull
;
protected
HullOptimizedRepresentationV3
hull
;
protected
Node
parent
;
protected
Node
parent
;
...
@@ -31,7 +30,7 @@ public abstract class Node implements Serializable {
...
@@ -31,7 +30,7 @@ public abstract class Node implements Serializable {
this
.
objectToNodeDistance
=
objectToNodeDistance
;
this
.
objectToNodeDistance
=
objectToNodeDistance
;
}
}
public
static
InternalNode
createParent
(
Se
t
<
Node
>
nodes
,
PrecomputedDistances
distances
,
InsertType
insertType
,
ObjectToNodeDistance
objectToNodeDistance
)
{
public
static
InternalNode
createParent
(
Lis
t
<
Node
>
nodes
,
PrecomputedDistances
distances
,
InsertType
insertType
,
ObjectToNodeDistance
objectToNodeDistance
)
{
List
<
LocalAbstractObject
>
objects
=
nodes
.
stream
()
List
<
LocalAbstractObject
>
objects
=
nodes
.
stream
()
.
map
(
Node:
:
getObjects
)
.
map
(
Node:
:
getObjects
)
.
flatMap
(
Collection:
:
stream
)
.
flatMap
(
Collection:
:
stream
)
...
@@ -41,14 +40,11 @@ public abstract class Node implements Serializable {
...
@@ -41,14 +40,11 @@ public abstract class Node implements Serializable {
}
}
public
double
getDistance
(
LocalAbstractObject
object
)
{
public
double
getDistance
(
LocalAbstractObject
object
)
{
switch
(
objectToNodeDistance
)
{
return
objectToNodeDistance
.
getDistance
(
object
,
this
);
case
FURTHEST_HULL_OBJECT:
}
return
getFurthestDistance
(
object
);
case
AVERAGE_DISTANCE:
public
double
getNearestDistance
(
LocalAbstractObject
object
)
{
return
getAverageDistance
(
object
);
return
ObjectToNodeDistance
.
NEAREST_HULL_OBJECT
.
getDistance
(
object
,
this
);
default
:
return
getNearestDistance
(
object
);
}
}
}
public
boolean
isCovered
(
LocalAbstractObject
object
)
{
public
boolean
isCovered
(
LocalAbstractObject
object
)
{
...
@@ -80,11 +76,9 @@ public abstract class Node implements Serializable {
...
@@ -80,11 +76,9 @@ public abstract class Node implements Serializable {
public
abstract
Set
<
LocalAbstractObject
>
getObjects
();
public
abstract
Set
<
LocalAbstractObject
>
getObjects
();
public
abstract
boolean
contains
(
LocalAbstractObject
object
);
public
abstract
int
getHeight
();
public
abstract
int
getHeight
();
public
abstract
Se
t
<
Node
>
getNodesOnLevel
(
int
level
);
public
abstract
Lis
t
<
Node
>
getNodesOnLevel
(
int
level
);
protected
void
rebuildHull
(
LocalAbstractObject
object
)
{
protected
void
rebuildHull
(
LocalAbstractObject
object
)
{
List
<
LocalAbstractObject
>
objects
=
new
ArrayList
<>(
getObjects
());
List
<
LocalAbstractObject
>
objects
=
new
ArrayList
<>(
getObjects
());
...
@@ -104,24 +98,4 @@ public abstract class Node implements Serializable {
...
@@ -104,24 +98,4 @@ public abstract class Node implements Serializable {
rebuildHull
(
object
);
rebuildHull
(
object
);
}
}
public
double
getNearestDistance
(
LocalAbstractObject
object
)
{
return
hull
.
getHull
().
stream
()
.
mapToDouble
(
object:
:
getDistance
)
.
min
()
.
orElse
(
Double
.
MAX_VALUE
);
}
private
double
getFurthestDistance
(
LocalAbstractObject
object
)
{
return
hull
.
getHull
().
stream
()
.
mapToDouble
(
object:
:
getDistance
)
.
max
()
.
orElse
(
Double
.
MIN_VALUE
);
}
private
double
getAverageDistance
(
LocalAbstractObject
object
)
{
return
hull
.
getHull
().
stream
()
.
mapToDouble
(
object:
:
getDistance
)
.
sum
()
/
hull
.
getHull
().
size
();
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment