我有以下igraph(g)的边缘:
from to
1 3
1 5
2 1
2 3
3 1
4 5
4 1
我用过:
g<- make_empty_graph(n=5) %>%
add_edges(c(1,3, 1,5, 2,1, 2,3, 3,1, 4,5, 4,1)) %>%
set_edge_attr("color", value = "red")
E(g)[[]]
plot(g)
我通过
计算了indegreeg_in <- degree(g, mode='in")
g_in
[1] 3 0 2 0 2
我想创建一个结合g和g_in的数据帧,如下所示:
from to in_degree
1 3 2
1 5 2
2 1 3
2 3 2
3 1 3
4 5 2
4 1 3
也就是说,将&#34;的in_degree与节点&#34;结合起来。只要。 我该怎么做?
答案 0 :(得分:0)
以这种方式:
render() {
const {
children,
contentContainerStyle,
record,
resource,
basePath,
translate,
version,
} = this.props;
let changedChildren = children;
if (record.excludeTab) {
changedChildren = [];
for (let i=0; i<children.length; i++) {
if (children[i] instanceof Array) {
changedChildren.push(children[i]);
} else if (children[i] instanceof Object
&& children[i].props.label !== "TabToExcludeLabel") {
changedChildren.push(children[i]);
}
}
}
return (
<div style={divStyle} key={version}>
<Tabs
value={this.state.value}
onChange={this.handleChange}
contentContainerStyle={contentContainerStyle}
>
{React.Children.map(
changedChildren,
(tab, index) => ....
)
}
我首先创建从顶点到其内部的映射,
data$in_degree <- setNames(degree(g, mode = "in"), V(g))[data$to]
# from to in_degree
# 1 1 3 2
# 2 1 5 2
# 3 2 1 3
# 4 2 3 2
# 5 3 1 3
# 6 4 5 2
# 7 4 1 3
然后将其应用于setNames(degree(g, mode = "in"), V(g))
# 1 2 3 4 5
# 3 0 2 0 2
。