regraph 계층 구조에서 가장자리 속성을 자리 표시자로 사용하는 방법이 있습니까? (Is there a way to have edge attributes as placeholders in a regraph hierarchy?)


문제 설명

regraph 계층 구조에서 가장자리 속성을 자리 표시자로 사용하는 방법이 있습니까? (Is there a way to have edge attributes as placeholders in a regraph hierarchy?)

저는 networkx를 기반으로 하는 regraph 라이브러리를 사용하는 python 스크립트를 작성 중입니다. 서로 입력되는 서로 다른 그래프가 포함된 계층 구조를 만들었습니다. 그래프 중 하나에서 모서리에 이름과 같은 속성이 있기를 원합니다. 이 작업을 수행하면 입력된 그래프에 정확히 동일한 가장자리 속성이 없기 때문에 동형이 깨졌다는 메시지가 나타납니다.

이것이 regraph가 설계된 목적이 아닐 수도 있음을 압니다. , 하지만 계층 구조의 그래프에서 edge 속성을 지정하는 방법이나 패턴뿐만 아니라 노드 이름도 고려하는 규칙이 있습니까?

다른 속성에 빈 속성을 추가하려고 이미 시도했습니다. 계층 구조의 그래프에서는 작동하지 않습니다.

hierarchy = rg.NetworkXHierarchy()

g_type = nx.DiGraph()
g_type.add_nodes_from(['list', 'number'])
g_type.add_edges_from([('list', 'number')])

g_obj = nx.DiGraph()
g_obj.add_nodes_from(['A', 'a'])
rg.add_edge(g_obj, 'A', 'a', attrs={'name': 'input'})

hierarchy.add_graph('type', g_type)
hierarchy.add_graph('obj', g_obj)

hierarchy.add_typing('obj', 'type', {'A': 'list', 'a': 'number'})

그래프의 가장자리에 속성 이름이 있고,


참조 솔루션

방법 1:

For people who are interested, here is how I managed to solve the problem:

hierarchy = rg.NetworkXHierarchy()

g_type = nx.DiGraph()
g_type.add_nodes_from(['list', 'number'])
g_type.add_edges_from([('list', 'number')])
rg.add_edge_attr(g_type, 'list', 'number', attrs={'name': rg.UniversalSet()})

g_obj = nx.DiGraph()
g_obj.add_nodes_from(['A', 'a'])
rg.add_edge(g_obj, 'A', 'a', attrs={'name': 'input'})

hierarchy.add_graph('type', g_type)
hierarchy.add_graph('obj', g_obj)

hierarchy.add_typing('obj', 'type', {'A': 'list', 'a': 'number'})

You simply have to add the same attribute with an rg.UniversalSet as value.

(by Fabian SchulzFabian Schulz)

참조 문서

  1. Is there a way to have edge attributes as placeholders in a regraph hierarchy? (CC BY‑SA 2.5/3.0/4.0)

#networkx #Python #hierarchy






관련 질문

단순 팻테일 로그 비닝 (Simple fat-tailed log-binning)

NetworkX - 노드 묶기 중지 - 시도된 Scale/K 매개변수 (NetworkX - Stop Nodes from Bunching Up - Tried Scale/K parameters)

문자열의 int 부분으로 문자열 레이블의 노드에 액세스 (Access a node of string label with an int part of the string)

시계열 분석을 위해 Pandas Groupby 및 date_range를 사용하는 동안 오류가 발생했습니다. (Error using Pandas Groupby and date_range for timeseries analysis)

regraph 계층 구조에서 가장자리 속성을 자리 표시자로 사용하는 방법이 있습니까? (Is there a way to have edge attributes as placeholders in a regraph hierarchy?)

networkx .module 'matplotlib.pyplot'에서 그래프를 그리는 동안 오류가 발생했습니다. (Error while drawing a graph in networkx .module 'matplotlib.pyplot' has no attribute 'ishold')

svg의 NetworkX node_shape (NetworkX node_shape from svg)

그래프를 통해 그래프 노드인 클래스 인스턴스의 속성에 액세스하는 방법은 무엇입니까? (How to access attributes of a class instance which is a graph node via the graph?)

그래프의 이미지를 분리하는 방법은 무엇입니까? (How to separate images of graphs?)

networkx 도면을 업데이트하는 방법 (How to update a networkx drawing)

그래프 노드 간의 메시지 흐름을 위한 Python 함수 (Python function for message flow between nodes of a graph)

networkx에서 임의의 에지 가중치를 사용하여 여러 임의의 그래프를 효율적으로 생성하는 방법 (How to efficiently generate multiple random graphs with random edge weights in networkx)







코멘트