[Fortran] 纯文本查看 复制代码
program main
implicit none
integer,parameter :: nvtxs=15,Edges=22
integer :: xadj(nvtxs+1),adjncy(2*Edges)
integer :: part(nvtxs)
integer :: npart = 2
!***********metis 4.0.1***********
integer :: option(5) = [ 0, 0, 0, 0, 0 ]
integer :: edgecut
integer :: wgtflag = 0
integer :: numflag = 1
integer :: vwgt, adjwgt
!***********metis 5.1.0************
integer :: ncon =1
integer :: options(40)
integer :: objval
!**********Graph Data**************
xadj=[0, 2, 5, 8, 11, 13, 16, 20, 24, 28, 31, 33, 36, 39, 42, 44]
adjncy=[1, 5, 0, 2, 6, 1, 3, 7, 2, 4, 8, 3, 9, 0, 6, 10, 1, 5, 7, 11, 2, 6, 8, 12, 3, 7, 9, 13, 4, 8, 14, 5, 11, 6, 10, 12, 7, 11, 13, 8, 12, 14, 9, 13]
!***********metis 4.0.1***********
!参数vwgt,adjwgt等传0值进去就行了。
! call METIS_PartGraphRecursive(nvtxs,xadj,adjncy,vwgt,adjwgt,wgtflag,numflag,npart,option, edgecut, part)
!***********metis 5.1.0************
!会提示错误。原因是参数NULL()在c中(NULL()==NULL)不成立
call METIS_SetDefaultOptions(options)
options(18) =1
call METIS_PartGraphRecursive(nvtxs,ncon,xadj,adjncy,NULL(), NULL(), NULL(), npart, &
& NULL(), NULL(), options,objval,part)
write(*,*) '**********************'
write(*,*) part
write(*,*) '**********************'
end program main