2014-11-19 3 views
1

Я пытаюсь удалить вершины из графика в igraph, и он не работает. Я думаю, что проблема может быть связана судалять вершины, используя которые на векторе igraph

> toosmall <- which(V(g)$coreness.all <= 5) 

как представляется, возвращает целое число (0).

Как удалить вершины из графика ниже?

> graph.coreness(g) 
    [1] 1 19 1 3 17 19 5 19 19 19 19 7 19 18 17 12 12 19 19 17 16 19 3 3 7 12 18 4 5 12 12 3 1 6 19 5 19 19 3 19 17 17 19 19 5 1 1 7 8 19 1 2 
    [53] 7 3 17 5 4 19 3 16 1 3 13 3 14 10 10 13 8 18 18 12 6 10 12 14 11 16 12 7 5 7 5 10 15 16 10 3 5 5 16 16 16 13 16 16 16 16 16 15 10 6 2 1 
[105] 14 16 16 11 5 11 16 11 10 16 2 14 7 8 1 10 12 12 12 19 8 10 7 5 13 3 19 16 3 4 4 19 13 7 16 13 11 13 15 13 3 2 3 3 2 9 14 16 16 14 16 13 
[157] 13 15 13 11 12 11 1 1 11 19 7 3 19 3 7 5 19 19 19 19 19 19 19 18 19 11 13 17 4 19 16 19 11 9 9 12 19 16 11 19 4 7 4 19 6 6 9 2 15 8 7 5 
[209] 10 7 3 10 6 8 4 11 13 2 7 6 7 6 9 4 3 3 13 3 13 9 4 13 5 5 6 6 6 14 8 2 5 7 7 14 7 9 6 8 12 1 1 1 14 1 10 8 16 2 6 9 
[261] 3 7 14 16 15 2 5 1 4 7 17 7 6 4 11 8 9 15 4 4 15 1 5 5 3 6 1 2 2 4 4 1 5 1 6 1 5 5 3 2 3 3 6 6 6 3 2 8 5 6 3 3 
[313] 2 1 5 2 12 3 1 6 1 2 5 2 1 3 1 1 8 2 3 
> toosmall <- which(V(g)$coreness.all <= 5) 
> delete.vertices(g,toosmall) 
IGRAPH U--- 331 2771 -- 
+ attr: Color (v/c), Shape (v/c), Size (v/c), Opacity (v/c), Image File (v/c), Visibility (v/c), Label (v/c), Label Fill Color (v/c), Label 
    Position (v/c), Tooltip (v/c), Layout Order (v/c), X (v/c), Y (v/c), Locked? (v/c), Polar R (v/c), Polar Angle (v/c), Degree (v/c), In-Degree 
    (v/c), Out-Degree (v/c), Betweenness Centrality (v/c), Closeness Centrality (v/c), Eigenvector Centrality (v/c), PageRank (v/c), Clustering 
    Coefficient (v/c), Reciprocated Vertex Pair Ratio (v/c), ID (v/c), Dynamic Filter (v/c), Add Your Own Columns Here (v/c), Followed (v/c), 
    Followers (v/c), Tweets (v/c), Favorites (v/c), Time Zone UTC Offset (Seconds) (v/c), Description (v/c), Location (v/c), Web (v/c), Time Zone 
    (v/c), Joined Twitter Date (UTC) (v/c), User of Interest? (v/c), Custom Menu Item Text (v/c), Custom Menu Item Action (v/c), id (v/c), Color 
    (e/c), Width (e/c), Style (e/c), Opacity (e/c), Visibility (e/c), Label (e/c), Label Text Color (e/c), Label Font Size (e/c), Reciprocated? 
    (e/c), ID (e/c), Dynamic Filter (e/c), Add Your Own Columns Here (e/c), Relationship (e/c), Relationship Date (UTC) (e/c), Tweet (e/c), URLs 
    in Tweet (e/c), Domains in Tweet (e/c), Hashtags in Tweet (e/c), Tweet Date (UTC) (e/c), Twitter Page for Tweet (e/c), Latitude (e/c), 
    Longitude (e/c), Imported ID (e/c), In-Reply-To Tweet ID (e/c), Edge Weight (e/c) 
> g 
IGRAPH U--- 331 2771 -- 
+ attr: Color (v/c), Shape (v/c), Size (v/c), Opacity (v/c), Image File (v/c), Visibility (v/c), Label (v/c), Label Fill Color (v/c), Label 
    Position (v/c), Tooltip (v/c), Layout Order (v/c), X (v/c), Y (v/c), Locked? (v/c), Polar R (v/c), Polar Angle (v/c), Degree (v/c), In-Degree 
    (v/c), Out-Degree (v/c), Betweenness Centrality (v/c), Closeness Centrality (v/c), Eigenvector Centrality (v/c), PageRank (v/c), Clustering 
    Coefficient (v/c), Reciprocated Vertex Pair Ratio (v/c), ID (v/c), Dynamic Filter (v/c), Add Your Own Columns Here (v/c), Followed (v/c), 
    Followers (v/c), Tweets (v/c), Favorites (v/c), Time Zone UTC Offset (Seconds) (v/c), Description (v/c), Location (v/c), Web (v/c), Time Zone 
    (v/c), Joined Twitter Date (UTC) (v/c), User of Interest? (v/c), Custom Menu Item Text (v/c), Custom Menu Item Action (v/c), id (v/c), Color 
    (e/c), Width (e/c), Style (e/c), Opacity (e/c), Visibility (e/c), Label (e/c), Label Text Color (e/c), Label Font Size (e/c), Reciprocated? 
    (e/c), ID (e/c), Dynamic Filter (e/c), Add Your Own Columns Here (e/c), Relationship (e/c), Relationship Date (UTC) (e/c), Tweet (e/c), URLs 
    in Tweet (e/c), Domains in Tweet (e/c), Hashtags in Tweet (e/c), Tweet Date (UTC) (e/c), Twitter Page for Tweet (e/c), Latitude (e/c), 
    Longitude (e/c), Imported ID (e/c), In-Reply-To Tweet ID (e/c), Edge Weight (e/c) 
> g <- delete.vertices(g,toosmall) 
> g 
IGRAPH U--- 331 2771 -- 
+ attr: Color (v/c), Shape (v/c), Size (v/c), Opacity (v/c), Image File (v/c), Visibility (v/c), Label (v/c), Label Fill Color (v/c), Label 
    Position (v/c), Tooltip (v/c), Layout Order (v/c), X (v/c), Y (v/c), Locked? (v/c), Polar R (v/c), Polar Angle (v/c), Degree (v/c), In-Degree 
    (v/c), Out-Degree (v/c), Betweenness Centrality (v/c), Closeness Centrality (v/c), Eigenvector Centrality (v/c), PageRank (v/c), Clustering 
    Coefficient (v/c), Reciprocated Vertex Pair Ratio (v/c), ID (v/c), Dynamic Filter (v/c), Add Your Own Columns Here (v/c), Followed (v/c), 
    Followers (v/c), Tweets (v/c), Favorites (v/c), Time Zone UTC Offset (Seconds) (v/c), Description (v/c), Location (v/c), Web (v/c), Time Zone 
    (v/c), Joined Twitter Date (UTC) (v/c), User of Interest? (v/c), Custom Menu Item Text (v/c), Custom Menu Item Action (v/c), id (v/c), Color 
    (e/c), Width (e/c), Style (e/c), Opacity (e/c), Visibility (e/c), Label (e/c), Label Text Color (e/c), Label Font Size (e/c), Reciprocated? 
    (e/c), ID (e/c), Dynamic Filter (e/c), Add Your Own Columns Here (e/c), Relationship (e/c), Relationship Date (UTC) (e/c), Tweet (e/c), URLs 
    in Tweet (e/c), Domains in Tweet (e/c), Hashtags in Tweet (e/c), Tweet Date (UTC) (e/c), Twitter Page for Tweet (e/c), Latitude (e/c), 
    Longitude (e/c), Imported ID (e/c), In-Reply-To Tweet ID (e/c), Edge Weight (e/c) 
> toosmall 
integer(0) 

ответ

3

Я думаю, вы должны определить toosmall как:

toosmall <- which(graph.coreness(g) <= 5) 

Вот работал пример, используя построенный график, в котором я использую более низкий порог в качестве критерия удаления:

# Create a graph 
g <- graph.ring(10) 
g <- add.edges(g, c(1,2, 2,3, 1,3)) 
graph.coreness(g) 

# Identify vertices with coresness <= threshold 
toosmall <- which(graph.coreness(g) <= 2) 

# Delete vertices and plot 
gp <- delete.vertices(g, toosmall) 
plot(gp) 

enter image description here

Смежные вопросы