Comments (5)
Instead of identical(index, V(graph))
use all(index == V(graph))
.
Straightforward and easy to understand.
from rigraph.
@maelle,
I am afraid this is not going to work.
Because of the <weak reference>
in V(g).
For example, consider:
g1 <- make_graph(c(1, 2, 3, 4))
index <- V(g1)
identical(index, V(g1))
# FALSE
# delete all vertices
g2 <- delete_vertices(g1, V(g1))
identical(V(g2), V(g2))
# FALSE
# This works for empty and non-empty sets V().
# For example.
all(V(g2) == seq_len(vcount(g2)))
# TRUE
all(index == seq_len(vcount(g1)))
# TRUE
all(index == V(g1))
#TRUE
Function identical()
could be too strong.
Note thatidentical(1:4, c(1, 2, 3, 4))
returns FALSE.
Both parameters do not have the same class.
from rigraph.
would equal work? feel free to suggest a change directly on the PR. I any case, thanks a ton!
from rigraph.
My point about V(g)
not being the same as 1:vcount
was a general one. I did not have the time / chance to understand the issue you were working on in detail.
Maybe this perspective helps clarify what I meant:
distances(g, 1, V(g)
will be faster than distances(g, 1, 1:vcount(g))
, even though they are semantically equivalent. This is because V(g)
indicates "all vertices" in a more efficient manner, and in a way that can be tested for in the C core, to help choose a better algorithm. Some algorithms are specialized for the "all vertices" case and the performance difference can be quite significant. From memory, some variants of transitivity()
as well as igraph_ecc()
should show a considerable difference.
from rigraph.
Generally, I would recommend introducing a helper function to check if a vertex sequence vs
includes all vertices in standard order.
I think all(vs == seq_len(vcount(g))
should work (as @clpippel says), but keep in mind that I don't know any R (!!). An optimization can/should be added to check attr(vs, 'is_all')
. This is TRUE
for V(g)
specifically. All this assumes that vs
is indeed of class igraph.vs
.
from rigraph.
Related Issues (20)
- revdeps HOT 13
- `cluster_label_prop()` crashes R when using fixed labels HOT 6
- Export `.from` etc. with behavior similar to `dplyr::across()` HOT 1
- use lifecyle for layout.fruchterman.reingold()
- Remove/deprecate the functions using constructor_spec()? HOT 1
- deprecate neimode argument in bfs() for good
- `feedback_arc_set()` needs tests
- Add `igraph_feedback_vertex_set()`
- A weights vector in `local_scan`
- TODOs in `rinterface_extra.c`
- TODOs in tests HOT 17
- TODO in `src/igraph_vector.hpp` HOT 2
- TODOs in `socnet.R` HOT 7
- TODO in tkplot
- ensure max.print is used consistently in all of print.R
- Update `is_separator()` docs
- can indexing be made faster HOT 1
- can we remove the "## TODO: speed this up" in make.R?
- Add `igraph_find_cycle()`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rigraph.