subroutine digraph_adj_example_abc ( A ) !*****************************************************************************80 ! !! digraph_adj_example_abc() sets up the adjacency matrix associated with a network. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 10 April 2026 ! ! Author: ! ! John Burkardt ! ! Output: ! ! integer A(3,3): an adjacency matrix. ! implicit none integer, parameter :: node_num = 3 integer A(node_num,node_num) A = reshape ( (/ & 0, 1, 0, & 0, 0, 1, & 1, 0, 0 /), (/ node_num, node_num /) ) A = transpose ( A ) return end subroutine digraph_adj_example_abcd ( A ) !*****************************************************************************80 ! !! digraph_adj_example_abcd() sets up the adjacency matrix associated with a network. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 10 April 2026 ! ! Author: ! ! John Burkardt ! ! Output: ! ! integer A(4,4): an adjacency matrix. ! implicit none integer, parameter :: node_num = 4 integer A(node_num,node_num) A = reshape ( (/ & 0, 1, 0, 0, & 0, 0, 1, 0, & 1, 0, 0, 1, & 1, 0, 0, 0/), (/ node_num, node_num /) ) A = transpose ( A ) return end subroutine digraph_adj_example_cycler ( A ) !*****************************************************************************80 ! !! digraph_adj_example_cycler() sets adjacency information for the cycler digraph. ! ! Diagram: ! ! A ! V ! 9--><--7---<--3--><---4 ! | /| / ! V A | / ! | / | / ! 5----<----1 V A ! | / | / ! V A | / ! | / |/ ! 2-->---8---<--6 ! \------>----/ ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 22 October 1999 ! ! Author: ! ! John Burkardt ! ! Output: ! ! integer A(9,9), the adjacency information. ! ADJ(I,J) is 1 if there is a direct link from node I to node J. ! implicit none integer, parameter :: node_num = 9 integer A(node_num,node_num) A(1:node_num,1:node_num) = 0 A(1,3) = 1 A(1,5) = 1 A(2,6) = 1 A(2,8) = 1 A(3,4) = 1 A(3,6) = 1 A(3,7) = 1 A(4,3) = 1 A(5,2) = 1 A(6,4) = 1 A(6,8) = 1 A(7,7) = 1 A(7,9) = 1 A(8,1) = 1 A(9,5) = 1 A(9,7) = 1 return end subroutine digraph_adj_print ( A, node_num, title ) !*****************************************************************************80 ! !! digraph_adj_print() prints out an adjacency matrix for a digraph. ! ! Discussion: ! ! This routine actually allows the entries to have ANY value. ! Values between 0 and 9 will be printed as is. Other values will ! be printed as '*'. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 04 July 2000 ! ! Author: ! ! John Burkardt ! ! Input: ! ! integer A(node_num,node_num), the adjacency matrix of a ! digraph. A(I,J) is 1 if there is a direct connection FROM node I TO ! node J, and is 0 otherwise. ! ! integer node_num: the number of nodes. ! ! character ( len = * ) TITLE, a title. ! implicit none integer node_num integer A(node_num,node_num) integer i integer j integer jhi character ( len = 80 ) string character ( len = * ) title if ( len_trim ( title ) /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) trim ( title ) end if write ( *, '(a)' ) ' ' do i = 1, node_num jhi = min ( node_num, 80 ) do j = 1, jhi if ( 0 <= A(i,j) .and. A(i,j) <= 9 ) then string(j:j) = char ( 48 + A(i,j) ) else string(j:j) = '*' end if end do write ( *, '(i2,2x,a)' ) i, string(1:jhi) end do return end subroutine digraph_adj_example_five ( A ) !*****************************************************************************80 ! !! digraph_adj_example_five() sets up the adjacency matrix associated with a network. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 10 April 2026 ! ! Author: ! ! John Burkardt ! ! Output: ! ! integer A(5,5): an adjacency matrix. ! implicit none integer, parameter :: node_num = 5 integer A(node_num,node_num) A = reshape ( (/ & 0, 1, 0, 0, 0, & 0, 0, 0, 0, 1, & 1, 0, 0, 0, 0, & 1, 0, 0, 0, 0, & 1, 0, 0, 0, 0 /), (/ node_num, node_num /) ) A = transpose ( A ) return end subroutine digraph_adj_example_moler ( A ) !*****************************************************************************80 ! !! digraph_adj_example_moler() returns the adjacency matrix for Moler's example 3. ! ! Discussion: ! ! This matrix appears on page 5 of the reference. ! ! We added a self-link for node 5, which otherwise has no outlinks. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 10 April 2026 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Cleve Moler, ! Experiments with Matlab, ! Chapter 7: Google PageRank, ! https://www.mathworks.com/moler/exm/chapters/pagerank.pdf ! ! Output: ! ! integer A(6,6), the adjacency matrix. ! implicit none integer, parameter :: node_num = 6 integer A(node_num,node_num) A = reshape ( (/ & 0, 1, 0, 0, 0, 1, & 0, 0, 1, 1, 0, 0, & 0, 0, 0, 1, 1, 1, & 1, 0, 0, 0, 0, 0, & 0, 0, 0, 0, 1, 0, & 1, 0, 0, 0, 0, 0/), (/ node_num, node_num /) ) A = transpose ( A ) return end subroutine digraph_adj_example_sauer ( A ) !*****************************************************************************80 ! !! digraph_adj_example_sauer() sets up the adjacency matrix associated with a network. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 10 April 2026 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Timothy Sauer, ! "How search engines rate page quality", ! Numerical Analysis, ! Pearson, 2006. ! ISBN: 0-321-2698-9, ! LC: QA297.S348 ! ! Output: ! ! integer A(15,15): an adjacency matrix. ! implicit none integer, parameter :: node_num = 15 integer A(node_num,node_num) A = reshape ( (/ & 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, & 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, & 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, & 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, & 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, & 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, & 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, & 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, & 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, & 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, & 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, & 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, & 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, & 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, & 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0/), (/ node_num, node_num /) ) A = transpose ( A ) return end subroutine digraph_adj_example_sixty ( A ) !*****************************************************************************80 ! !! digraph_adj_example_sixty() sets the adjacency matrix for the sixty digraph. ! ! Discussion: ! ! The nodes of the digraph are divisors of 60. There is a link from I to ! J if divisor I can be divided by divisor J. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 11 August 2000 ! ! Author: ! ! John Burkardt ! ! Output: ! ! integer A(node_num,node_num), the adjacency information. ! A(I,J) is 1 if there is a direct link from node I to node J. ! implicit none integer, parameter :: node_num = 12 integer A(node_num,node_num) integer d(node_num) integer i integer j d(1:12) = (/ 60, 30, 20, 15, 12, 10, 6, 5, 4, 3, 2, 1 /) do i = 1, node_num do j = 1, node_num if ( i == j ) then A(i,j) = 0 else if ( mod ( d(i), d(j) ) == 0 ) then A(i,j) = 1 else A(i,j) = 0 end if end do end do return end