In R, how can I generate a subgraph from a igraph object based on multiple attribute scores?

wake_wake

I have a igraph object with 3000 vertices and 4000 edges. Both vertices and edges hold attributes.

One of the vertex attributes is city and has a valid input for all vertices.

I want to select all vertices that live in the top 10 most common cities and create a new graph for these. I know what these top 10 cities are.

When I do so for a single city, it works fine:

new_graph<-induced.subgraph(old_graph, which(V(old_graph$city=="LOS ANGELES")

However, I do want to include 9 more cities into the new_graph.

Can I simple extent my which argument here? Or should I write a loop?

Does anyone has some ideas? Any help will greatly be appreciated!

MrFlick

Rather than testing for equality, you can use the %in% operator to match any value in a list. Just use

new_graph<-induced.subgraph(old_graph, 
  which(V(old_graph)$city %in% c("LOS ANGELES","BOSTON","KALAMAZOO")))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

R and igraph: subgraph nodes based on attributes of other nodes that are incident on edge

From Dev

How can I calculate factor scores with R?

From Dev

R - Problems with igraph: Why isn't the option "simplify" working? And how can I generate an EPS of the output?

From Dev

(R Igraph) Using affilliation to create subgraph from adjacency matrix

From Dev

Igraph in R: how to change edge color based on edge attribute

From Dev

Creating Subgraph using igraph in R

From Dev

How do I obtain latent trait scores from a merMod object in R?

From Dev

How can I generate GN benchmark graphs for community detection in igraph?

From Dev

How can I generate multiple pages from a JSON file with Assemble

From Dev

Using JAXB, how can I unmarshal an XMLelement with an attribute-defined type to an object based on that attribute?

From Dev

How to get multiple means scores from a variable in R

From Dev

How can I calculate average scores from these entries in django?

From Dev

How can I calculate average scores from these entries in django?

From Dev

r igraph - Identify ties of nodes to a subgraph regardless of affiliation to said subgraph

From Dev

How do i generate a new immutable object based from a object defined with type in f#?

From Dev

How to convert a Networkx Graph into an igraph object (from python to R)

From Dev

How can I remove objects from array based on multiple conditions?

From Dev

How can I assemble a new Operation from a subgraph, and apply gradient to the newly assembled operation

From Dev

How can i generate multiple VBO with an ByteBuffer

From Dev

R code: how to generate variable based on multiple conditions from other variables

From Dev

How can I generate an attribute within Devise registration?

From Dev

How can I generate a video from raw folder based on spinner selection?

From Dev

How can I save past high scores?

From Dev

How can I save past high scores?

From Dev

How can I generate permutations from this array?

From Dev

How can I generate a dictionary from a list?

From Dev

How Can I Define Only the Gradient for a Tensorflow Subgraph?

From Dev

Using IGraph in R, how to calculate highest/lowest edge attribute value from those connected to each vertex?

From Dev

Why can't I create a matrix based on as.matrix command from igraph formulas?

Related Related

  1. 1

    R and igraph: subgraph nodes based on attributes of other nodes that are incident on edge

  2. 2

    How can I calculate factor scores with R?

  3. 3

    R - Problems with igraph: Why isn't the option "simplify" working? And how can I generate an EPS of the output?

  4. 4

    (R Igraph) Using affilliation to create subgraph from adjacency matrix

  5. 5

    Igraph in R: how to change edge color based on edge attribute

  6. 6

    Creating Subgraph using igraph in R

  7. 7

    How do I obtain latent trait scores from a merMod object in R?

  8. 8

    How can I generate GN benchmark graphs for community detection in igraph?

  9. 9

    How can I generate multiple pages from a JSON file with Assemble

  10. 10

    Using JAXB, how can I unmarshal an XMLelement with an attribute-defined type to an object based on that attribute?

  11. 11

    How to get multiple means scores from a variable in R

  12. 12

    How can I calculate average scores from these entries in django?

  13. 13

    How can I calculate average scores from these entries in django?

  14. 14

    r igraph - Identify ties of nodes to a subgraph regardless of affiliation to said subgraph

  15. 15

    How do i generate a new immutable object based from a object defined with type in f#?

  16. 16

    How to convert a Networkx Graph into an igraph object (from python to R)

  17. 17

    How can I remove objects from array based on multiple conditions?

  18. 18

    How can I assemble a new Operation from a subgraph, and apply gradient to the newly assembled operation

  19. 19

    How can i generate multiple VBO with an ByteBuffer

  20. 20

    R code: how to generate variable based on multiple conditions from other variables

  21. 21

    How can I generate an attribute within Devise registration?

  22. 22

    How can I generate a video from raw folder based on spinner selection?

  23. 23

    How can I save past high scores?

  24. 24

    How can I save past high scores?

  25. 25

    How can I generate permutations from this array?

  26. 26

    How can I generate a dictionary from a list?

  27. 27

    How Can I Define Only the Gradient for a Tensorflow Subgraph?

  28. 28

    Using IGraph in R, how to calculate highest/lowest edge attribute value from those connected to each vertex?

  29. 29

    Why can't I create a matrix based on as.matrix command from igraph formulas?

HotTag

Archive