子图同构算法Ullmann实现,并采取了Refinement(java语言)

子图同构算法Ullmann早在1976年就提出来了,大家有兴趣可以自己去搜索下原文看看。这里我就简要的阐述一下。

给定两个图Q 和 G, 它们相应的矩阵分别是.我们的目标就是找到矩阵

算法步骤:

       Step1. Setup matrix Mn×m , such that M[i][j]=1, if 1) the i-th vertex in Q hasthe same label as the j-th vertex in G; and 2) the i-th vertex has smallervertex degree than the j-th vertex in G.

       Step2.MatrixesM are generated by systematically changing to 0 all but one of the 1’s in eachof the rows of M, subject to the definitory condition that no column of amatrix M may contain more than one 1. 

       Step3.Verify matrix M’ by the following equation

                

为了提高算法的效率,采用了如下的Refinement。

Refinement:

Letthe i-th vertex v in Q corresponds to the j-th vertex u in G.Each neighbor vertex of v in Q must correspond to some neighbor vertexof u in G.  Otherwise, vcannot correspond to u.

 1. Considering the matrix M, for each 1 in M, we refine it by the followingequation. If fails, change 1 to 0 in M.

      

 2.  If there exists at least one row (in M) having no 1, we report no subgraphisomorphism from Q to G.

接下来就直接粘贴代码了。


package ucas.iie.graph.action;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

import ucas.iie.graph.bean.EdgeBean;
import ucas.iie.graph.bean.GraphBean;
import ucas.iie.graph.bean.VertexBean;

public class IsomorphismImpl {
	private ArrayList<GraphBean> query_g;// 查询的子图
	private ArrayList<GraphBean> mydb_g;// 图的总数据

	public IsomorphismImpl() {
		query_g = new ArrayList<GraphBean>();
		mydb_g = new ArrayList<GraphBean>();
	}

	/**
	 * 
	 * @param query
	 *
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值