문제 설명
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 Schulz、Fabian Schulz)