#include <stdio.h>
#include<stdlib.h>
#define FALSE 0
#define TRUE 1
#define MAX 15
short int matrix[MAX][MAX] =
{{0, 0, 1, 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, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 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, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
typedef struct node *node_pointer; //노드
typedef struct node{
int vertex;
node_pointer link;
}listnode;
typedef struct{ //헤드
int count; // 진입차수 수(0이 되면 스택에 추가)
node_pointer link;
}hdnodes;
// 헤드 행렬 작성
hdnodes graph[MAX];
void topsort(hdnodes[], int);
void creation();
int main(){
creation();
printf("\n\n");
topsort(graph, MAX);
system("PAUSE");
return 0;
}
void topsort(hdnodes graph[], int n)
{
int i, j, k, top;
node_pointer ptr;
top = -1;
for(i=0;i<n;i++)
if (!graph[i].count)
{
graph[i].count = top;