简体   繁体   English

I 图中的度数

[英]Degrees in I graph

I am a Newbie in I-graph.我是 I-graph 的新手。 I wish to know.我想知道。

  1. How to isolate nodes with a specific degree value?如何隔离具有特定度值的节点?
  2. How to know their node IDs如何知道他们的节点ID
  3. Can we draw a new graph with degrees above the given thresholds.我们可以绘制一个度数高于给定阈值的新图吗? Say nodes graph with nodes > n?假设节点图的节点 > n?

If there is any more tutorial/book with a more involved treatment of degree function, please let me know如果还有更多涉及学位 function 处理的教程/书籍,请告诉我

Warm Regards温暖的问候

SHRINIVAS神殿

I think you can use the vertex function V() , degree() , and base R functions like which() to get what you want.我认为您可以使用顶点 function V()degree()和基础 R 函数,如which()来获得您想要的。 See below.见下文。

library(igraph)

set.seed(12345)
                                        # Generate a graph with a heterogeneous degree distribution
g <- sample_fitness_pl(
    no.of.nodes = 200,
    no.of.edges = 1000,
    exponent.out = 2
)
                                        # Plot to confirm
plot(g, vertex.label = "", vertex.size = 2)
                                        # Collect the degree sequence
k_i <- degree(g)
                                        # And the distinct observed degrees
k_bins <- sort(unique(k_i))
                                        # Plot the degree histogram
hist(k_i, breaks = 20)
                                        # Let's look at nodes with k_i = 10
n <- 10
                                        # We can use the base R function `which()` to return the node
                                        # IDs of those nodes with k_i = n
V(g)[which(k_i == n)]
## [1] 126 134 145 154

I think for (3) you want an induced subgraph with only those nodes with k_i > n.我认为对于 (3),您需要一个仅包含 k_i > n 的节点的导出子图。 However, in the induced subgraph, those nodes will not necessarily have the same degree as in the original graph.然而,在导出子图中,这些节点不一定具有与原始图中相同的度数。 If that isn't quite what you're looking for, see the manual here to see if there's a better option.如果这不是您想要的,请参阅此处的手册以查看是否有更好的选择。

                                        # These are the nodes with k_1 >= n
plot(g, vertex.label = "", vertex.size = 2, vertex.color = ifelse(k_i > n, 2, 1))

h <- induced_subgraph(
    g,
    vids = V(g)[which(k_i >= n)]
)

plot(h, vertex.label = "", vertex.size = 3, vertex.color = 2)

For books, you might try this one .对于书籍,您可以试试这本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 R:绘制著名的“6度分离”(凯文培根) - R: Plot the famous "6 degrees of separation" (Kevin Bacon) 有两个顶点的有向循环图吗? - can I have a directed cyclic graph with just two vertexes? 如何在图形dracula的多个节点上进行矩形选择? - How can I make rectangle selection on multiple nodes with graph dracula? 如何测试图中的节点是否连接(有边)? - How can I test whether a node is connected (with edges) in a graph? 构建图表时应如何检查唯一值? - How should I check for unique values while building a Graph? 如何从整个图形Gephi Toolkit中生成100个随机数的节点? - How can I generate 100 random number of nodes from the whole graph Gephi Toolkit? 我如何在这个简单的图中找到某个节点的所有传入弧/边 - How do i find all incoming arcs/edges of a certain node in this simple graph 我可以在一个无向图中正好访问每个节点一次的最大节点数是多少? - What is the maximum number of nodes I can traverse in an undirected graph visiting each node exactly once? 在加权无向图中,如何找到两个节点之间的固定长度路径? - In a weighted undirected graph, how do I find a fixed length path between two nodes? 我正在尝试填充图形,存储探索的节点的最优化方法是什么? - I am trying to fill a graph, what is the most optimized way to store the explored nodes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM