|

楼主 |
发表于 2004-3-25 08:45:47
|
显示全部楼层
[php]
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#define max_vertex_num 20
#define MAX_weight 30
#define NULL 0
/*This defination of the algraph structure*/
typedef struct arcnode{
int adjvex;
struct arcnode *nextarc;
int weight;
}arcnode;
typedef struct vnode{
unsigned int data; /*Record ip_adress */
arcnode *firstarc;
}vnode,adjlist[max_vertex_num];
struct algraph{
adjlist vertices;
int vexnum,arcnum;
};
int main(void)
{
struct algraph *g1,g2;
int fd[2];
pid_t id;
pipe(fd);
g2=(struct algraph *)malloc(sizeof(struct algraph));
creat_algraph(g);/*生成图的结构函数*/
if((pid=fork())==-1)
{
perror("fork");
exit(1);
}else if(pid==0)
{
close(fd[0]);
write(fd[1],g1,sizeof(struct algraph));
}
wait();
close(fd[1]);
read(fd[0],g2,sizeof(struct algraph));/*好像传不过来图中的数据*/
print_algraph(g2);/*打印图函数*/
exit(0);
}
[/php]
谢谢! |
|