Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
kwant
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kwant
kwant
Commits
fca192f8
Commit
fca192f8
authored
12 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
make CGraph.out_neighbors directly callable from Cython
parent
3a2fdf48
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kwant/graph/core.pxd
+4
-1
4 additions, 1 deletion
kwant/graph/core.pxd
kwant/graph/core.pyx
+13
-13
13 additions, 13 deletions
kwant/graph/core.pyx
with
17 additions
and
14 deletions
kwant/graph/core.pxd
+
4
−
1
View file @
fca192f8
...
...
@@ -16,7 +16,7 @@ cdef class Graph:
cdef
_add_edges_ndarray_int32
(
self
,
np
.
ndarray
[
np
.
int32_t
,
ndim
=
2
]
edges
)
cdef
class
gintArraySlice
:
cdef
gint
*
begin
,
*
end
cdef
gint
*
data
,
size
cdef
class
CGraph
:
cdef
readonly
bint
twoway
,
edge_nr_translation
...
...
@@ -25,6 +25,9 @@ cdef class CGraph:
cdef
gint
*
tails_idxs
,
*
tails
,
*
edge_ids
cdef
gint
*
edge_ids_by_edge_nr
,
edge_nr_end
cpdef
gintArraySlice
out_neighbors
(
self
,
gint
node
)
cdef
class
CGraph_malloc
(
CGraph
):
pass
...
...
This diff is collapsed.
Click to expand it.
kwant/graph/core.pyx
+
13
−
13
View file @
fca192f8
...
...
@@ -271,17 +271,17 @@ cdef class Graph:
cdef
class
gintArraySlice
:
def
__len__
(
self
):
return
self
.
end
-
self
.
begin
return
self
.
size
def
__getitem__
(
self
,
gint
key
):
cdef
gint
*
result_ptr
cdef
gint
index
if
key
>=
0
:
result_ptr
=
self
.
begin
+
key
index
=
key
else
:
result_ptr
=
self
.
end
+
key
if
result_ptr
<
self
.
begin
or
result_ptr
>=
self
.
end
:
index
=
self
.
size
+
key
if
index
<
0
or
index
>=
self
.
size
:
raise
IndexError
(
'
Index out of range.
'
)
return
result_ptr
[
0
]
return
self
.
data
[
index
]
cdef
class
EdgeIterator
:
def
__iter__
(
self
):
...
...
@@ -331,7 +331,7 @@ cdef class CGraph:
def
has_dangling_edges
(
self
):
return
not
self
.
num_edges
==
self
.
num_px_edges
==
self
.
num_xp_edges
def
out_neighbors
(
self
,
gint
node
):
cp
def
gintArraySlice
out_neighbors
(
self
,
gint
node
):
"""
Return the nodes a node points to.
Parameters
...
...
@@ -349,8 +349,8 @@ cdef class CGraph:
if
node
<
0
or
node
>=
self
.
num_nodes
:
raise
NodeDoesNotExistError
()
cdef
gintArraySlice
result
=
gintArraySlice
()
result
.
begin
=
&
self
.
heads
[
self
.
heads_idxs
[
node
]]
result
.
end
=
&
self
.
heads
[
self
.
heads_idxs
[
node
+
1
]]
result
.
data
=
&
self
.
heads
[
self
.
heads_idxs
[
node
]]
result
.
size
=
&
self
.
heads
[
self
.
heads_idxs
[
node
+
1
]]
-
result
.
data
return
result
def
out_edge_ids
(
self
,
gint
node
):
...
...
@@ -394,8 +394,8 @@ cdef class CGraph:
if
node
<
0
or
node
>=
self
.
num_nodes
:
raise
NodeDoesNotExistError
()
cdef
gintArraySlice
result
=
gintArraySlice
()
result
.
begin
=
&
self
.
tails
[
self
.
tails_idxs
[
node
]]
result
.
end
=
&
self
.
tails
[
self
.
tails_idxs
[
node
+
1
]]
result
.
data
=
&
self
.
tails
[
self
.
tails_idxs
[
node
]]
result
.
size
=
&
self
.
tails
[
self
.
tails_idxs
[
node
+
1
]]
-
result
.
data
return
result
def
in_edge_ids
(
self
,
gint
node
):
...
...
@@ -420,8 +420,8 @@ cdef class CGraph:
if
node
<
0
or
node
>=
self
.
num_nodes
:
raise
NodeDoesNotExistError
()
cdef
gintArraySlice
result
=
gintArraySlice
()
result
.
begin
=
&
self
.
edge_ids
[
self
.
tails_idxs
[
node
]]
result
.
end
=
&
self
.
edge_ids
[
self
.
tails_idxs
[
node
+
1
]]
result
.
data
=
&
self
.
edge_ids
[
self
.
tails_idxs
[
node
]]
result
.
size
=
&
self
.
edge_ids
[
self
.
tails_idxs
[
node
+
1
]]
-
result
.
data
return
result
def
has_edge
(
self
,
gint
tail
,
gint
head
):
...
...
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