isisomorphic
Determine whether two graphs are isomorphic
Description
tf = iSisomorphic(
用一个或多个名称值对参数指定其他选项。例如,您可以指定G1,G2
,Name,Value
)“节点”
和a list of node variables to indicate that the isomorphism must preserve these variables to be valid.
Examples
比较图
创建和绘制两个有向图,然后确定它们是否是同构。
G1 = digraph([1 1 1 2 3 4],[2 3 4 4 4 1]); G2 = digraph([3 3 3 2 1 4],[1 4 2 3 2 2]); subplot(1,2,1) plot(G1) subplot(1,2,2) plot(G2)
isisomorphic(G1,G2)
ans =logical1
将图形与不同的标签和布局进行比较
Create and plot two graphs,G1
和G2
。
G1 = graph([1 1 1 2 2 3 3 4 5 5 7 7],[2 4 5 3 6 4 7 8 6 8 6 8]); plot(G1,'XData',[1 4 4 1 2 3 3 2],'YData',[4 4 1 1 3 3 2 2])
G2 = graph({'a''a''a''b''b''b''c''c''c''d''d''d'},。。。{'g''h''i''g''h''j''g''i''j''h''i''j'});情节(g2,'XData',[1 2 2 2 2 1 2 1],,'YData',[4 4 3 2 3 1 2 1])
Determine whether an isomorphism exists forG1
和G2
。结果表明,尽管标签和布局不同,但图形在结构上是相同的。
tf = iSisomorphic(G1,G2)
tf =logical1
Preserve Node Properties in Isomorphism Comparison
采用two different comparisons to determine if there is an isomorphism relation between two graphs. One of the comparisons preserves a node property, while the other ignores it.
创建两个类似的图。添加节点属性Color
to each of the graphs.
G1 = graph({'d''e''f'},{'e''f''d'});G1.Nodes.Color = {'red''red''blue'}'; G2 = graph({'a''b''c'},{'b''c''a'});G2.Nodes.Color = {'blue''blue''red'}';
在同一图中并排绘制图形。为有红色的节点染色颜色='红色'
。
subplot(1,2,1) p1 = plot(G1); highlight(p1,{'d''e'},'NodeColor','r') subplot(1,2,2) p2 = plot(G2); highlight(p2,'c','NodeColor','r')
Determine if the graphs are isomorphic, ignoring theColor
property.
tf = iSisomorphic(G1,G2)
tf =logical1
Determine if the graphs are isomorphic and preserve the value of theColor
property in the comparison. In this case, there is no isomorphism since theColor
property of each graph contains different numbers of'red'
和'blue'
values.
tf = iSisomorphic(G1,G2,“节点”,'颜色')
tf =logical0
Input Arguments
Name-Value Arguments
将可选的参数对Name1=Value1,...,NameN=ValueN
, whereName
is the argument name and价值
是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。
Before R2021a, use commas to separate each name and value, and encloseName
in quotes.
Example:tf = iSisomorphic(G1,G2,'NodeVariables',{'Var1' 'Var2'})
EdgeVariables
—Edge variables to preserve
character vector|string scalar|cell array of character vectors|string array
Edge variables to preserve, specified as the comma-separated pair consisting of'EdgeVariables'
以及字符向量,字符串标量,字符矢量的单元格数或字符串数组。使用此选项来指定两者中的一个或多个边缘变量G1.Edges
和g2.edges
。同构比较必须保留指定的边缘变量才能有效。对于在相同两个节点之间具有多个边缘的多编码,相同节点对的边缘变量排序是无关的。
Data Types:char
|string
|cell
节点
—节点变量要保存
character vector|string scalar|cell array of character vectors|string array
节点变量要保留,指定为逗号分隔对“节点”
以及字符向量,字符串标量,字符矢量的单元格数或字符串数组。使用此选项来指定两者中的一个或多个节点变量G1.Nodes
和G2.Nodes
。The isomorphism comparison must preserve the specified node variables in order to be valid.
Data Types:char
|string
|cell
More About
图同构
Two graphs,G1
和G2
,如果存在节点的排列,则是同构P
such that重新订购(G2,P)
has the same structure asG1
。
Two graphs that are isomorphic have similar structure. For example, if a graph contains one cycle, then all graphs isomorphic to that graph also contain one cycle.
Version History
Apri esempio
如果dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai Fatto Clic Su Un Collegamento Che Corisponde A Questo Comando Matlab:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- AméricaLatina(Español)
- Canada(English)
- United States(English)
欧洲
- Belgium(English)
- 丹麦(English)
- Deutschland(德意志)
- España(Español)
- Finland(English)
- 法国(Français)
- 爱尔兰(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- 挪威(English)
- Österreich(德意志)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)