Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
3ab51f6e
Commit
3ab51f6e
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added DirectedEdgeBuilder
parent
5221e929
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-math/geometry/common.ts
+2
-2
2 additions, 2 deletions
src/mol-math/geometry/common.ts
src/mol-math/graph/int-adjacency-graph.ts
+69
-0
69 additions, 0 deletions
src/mol-math/graph/int-adjacency-graph.ts
with
71 additions
and
2 deletions
src/mol-math/geometry/common.ts
+
2
−
2
View file @
3ab51f6e
...
@@ -14,9 +14,9 @@ export interface PositionData {
...
@@ -14,9 +14,9 @@ export interface PositionData {
x
:
ArrayLike
<
number
>
,
x
:
ArrayLike
<
number
>
,
y
:
ArrayLike
<
number
>
,
y
:
ArrayLike
<
number
>
,
z
:
ArrayLike
<
number
>
,
z
:
ArrayLike
<
number
>
,
/
/
subset indices into the x/y/z/radius arrays
/
**
subset
of
indices into the x/y/z/radius arrays
*/
indices
:
OrderedSet
,
indices
:
OrderedSet
,
/
/
optional element radius
/
**
optional element radius
*/
radius
?:
ArrayLike
<
number
>
radius
?:
ArrayLike
<
number
>
}
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-math/graph/int-adjacency-graph.ts
+
69
−
0
View file @
3ab51f6e
...
@@ -160,6 +160,75 @@ export namespace IntAdjacencyGraph {
...
@@ -160,6 +160,75 @@ export namespace IntAdjacencyGraph {
}
}
}
}
export
class
DirectedEdgeBuilder
{
private
bucketFill
:
Int32Array
;
private
current
=
0
;
private
curA
:
number
=
0
;
offsets
:
Int32Array
;
edgeCount
:
number
;
/** the size of the A and B arrays */
slotCount
:
number
;
a
:
Int32Array
;
b
:
Int32Array
;
createGraph
<
EdgeProps
extends
IntAdjacencyGraph
.
EdgePropsBase
=
{}
>
(
edgeProps
?:
EdgeProps
)
{
return
create
(
this
.
offsets
,
this
.
a
,
this
.
b
,
this
.
edgeCount
,
edgeProps
);
}
/**
* @example
* const property = new Int32Array(builder.slotCount);
* for (let i = 0; i < builder.edgeCount; i++) {
* builder.addNextEdge();
* builder.assignProperty(property, srcProp[i]);
* }
* return builder.createGraph({ property });
*/
addNextEdge
()
{
const
a
=
this
.
xs
[
this
.
current
],
b
=
this
.
ys
[
this
.
current
];
const
oa
=
this
.
offsets
[
a
]
+
this
.
bucketFill
[
a
];
this
.
a
[
oa
]
=
a
;
this
.
b
[
oa
]
=
b
;
this
.
bucketFill
[
a
]
++
;
this
.
current
++
;
this
.
curA
=
oa
;
}
/** Builds property-less graph */
addAllEdges
()
{
for
(
let
i
=
0
;
i
<
this
.
edgeCount
;
i
++
)
{
this
.
addNextEdge
();
}
}
assignProperty
<
T
>
(
prop
:
{
[
i
:
number
]:
T
},
value
:
T
)
{
prop
[
this
.
curA
]
=
value
;
}
constructor
(
public
vertexCount
:
number
,
public
xs
:
ArrayLike
<
number
>
,
public
ys
:
ArrayLike
<
number
>
)
{
this
.
edgeCount
=
xs
.
length
;
this
.
offsets
=
new
Int32Array
(
this
.
vertexCount
+
1
);
this
.
bucketFill
=
new
Int32Array
(
this
.
vertexCount
);
const
bucketSizes
=
new
Int32Array
(
this
.
vertexCount
);
for
(
let
i
=
0
,
_i
=
this
.
xs
.
length
;
i
<
_i
;
i
++
)
bucketSizes
[
this
.
xs
[
i
]]
++
;
let
offset
=
0
;
for
(
let
i
=
0
;
i
<
this
.
vertexCount
;
i
++
)
{
this
.
offsets
[
i
]
=
offset
;
offset
+=
bucketSizes
[
i
];
}
this
.
offsets
[
this
.
vertexCount
]
=
offset
;
this
.
slotCount
=
offset
;
this
.
a
=
new
Int32Array
(
offset
);
this
.
b
=
new
Int32Array
(
offset
);
}
}
export
class
UniqueEdgeBuilder
{
export
class
UniqueEdgeBuilder
{
private
xs
:
number
[]
=
[];
private
xs
:
number
[]
=
[];
private
ys
:
number
[]
=
[];
private
ys
:
number
[]
=
[];
...
...
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