#include "def.h" #include "macro.h" /* pre version of graph */ /* grabasic.c */ /* AK 090889 */ #ifdef GRAPHTRUE OBJECTKIND s_gr_k(a) OP a; /* AK 210889 */ /* AK 210891 V1.3 */ { OBJECTSELF b; b = s_o_s(a); return(b.ob_graph->gr_kind); } #endif /* GRAPHTRUE */ #ifdef GRAPHTRUE OP s_gr_s(a) OP a; /* AK 210889 */ /* AK 210891 V1.3 */ { OBJECTSELF b; b = s_o_s(a); return(b.ob_graph->gr_self); } #endif /* GRAPHTRUE */ #ifdef GRAPHTRUE INT c_gr_s(a,c) OP a,c; /* AK 210889 */ /* AK 210891 V1.3 */ { OBJECTSELF b; b = s_o_s(a); b.ob_graph->gr_self = c; return(OK); } #endif #ifdef GRAPHTRUE INT c_gr_k(a,c) OP a; OBJECTKIND c; /* change_graph_kind */ /* AK 210889 */ /* AK 210891 V1.3 */ { OBJECTSELF b; b = s_o_s(a); (b.ob_graph)->gr_kind = c; return(OK); } #endif INT m_sk_gr(self,kind,erg) OP self,erg; OBJECTKIND kind; /* make_self_kind_graph */ /* AK 210889 */ /* AK 210891 V1.3 */ { #ifdef GRAPHTRUE struct graph *mallocerg; mallocerg = (struct graph *) malloc(sizeof(struct graph)); if (mallocerg == NULL) { error("m_sk_gr:no memory"); return(ERROR); } c_o_s(erg,mallocerg); c_o_k(erg,GRAPH); c_gr_k(erg,kind); c_gr_s(erg,self); return(OK); #else error("m_sk_gr:GRAPH not available"); return(ERROR); #endif } #ifdef GRAPHTRUE OP s_gr_kn(a) OP a; /* select_graph_knotenliste */ /* AK 210889 */ /* AK 210891 V1.3 */ { /* die knoten elemente sind das erste vector element im self vector */ OP h = s_gr_s(a); if (s_o_k(h) != VECTOR) { error("s_gr_kn:not VECTOR"); return(NULL); } return(s_v_i(h,0L)); } #endif OP s_gr_kni(a,i) OP a; INT i; /* select_graph_knotenliste das ite element*/ /* AK 210889 */ /* AK 210891 V1.3 */ { #ifdef GRAPHTRUE return(s_v_i(s_gr_kn(a),i)); #else error("s_gr_kni:GRAPH not available"); return(NULL); #endif } #ifdef GRAPHTRUE OP s_gr_na(a) OP a; /* select_graph_nachbarschaftsliste */ /* AK 210889 */ /* AK 210891 V1.3 */ { /* die nachbarschaftsliste ist das zweite vector element im self vector */ return(s_v_i(s_gr_s(a),1L)); } #endif OP s_gr_nai(a,i) OP a; INT i; /* select_graph_nachbarschaftsliste das ite Element, was selber ein VECTOR ist */ /* AK 210889 */ /* AK 210891 V1.3 */ { #ifdef GRAPHTRUE return(s_v_i(s_gr_na(a),i)); #else error("s_gr_nai:GRAPH not available"); return(NULL); #endif } #ifdef GRAPHTRUE OP s_gr_koor(a) OP a; /* select_graph_koordinaten */ /* AK 250889 */ /* AK 210891 V1.3 */ { /* die koordinatenliste ist das dritte vector element im self vector */ return(s_v_i(s_gr_s(a),2L)); } #endif OP s_gr_koori(a,i) OP a; INT i; /* select_graph_koordinatenliste das ite Element, was selber ein VECTOR ist */ /* AK 250889 */ /* AK 210891 V1.3 */ { #ifdef GRAPHTRUE return(s_v_i(s_gr_koor(a),i)); #else error("s_gr_koori:GRAPH not available"); return(NULL); #endif } OP s_gr_xkoori(a,i) OP a; INT i; /* select_graph_koordinatenliste das ite Element, was selber ein VECTOR ist und davon die xkoordinate */ /* AK 250889 */ /* AK 210891 V1.3 */ { #ifdef GRAPHTRUE return(s_v_i(s_gr_koori(a,i),0L)); #else error("s_gr_xkoori:GRAPH not available"); return(NULL); #endif } OP s_gr_ykoori(a,i) OP a; INT i; /* select_graph_koordinatenliste das ite Element, was selber ein VECTOR ist und davon die ykoordinate */ /* AK 250889 */ /* AK 210891 V1.3 */ { #ifdef GRAPHTRUE return(s_v_i(s_gr_koori(a,i),1L)); #else error("s_gr_ykoori:GRAPH not available"); return(NULL); #endif } #ifdef GRAPHTRUE INT m_vector_graph(vector,kf,erg) OP vector,erg; INT (* kf)(); /* macht aus einem vector von objecten und einer funktion kf die testet ob zwischen zwei objecten eine kante ist einen graphen */ /* kf gibt true oder false zurueck */ /* AK 210889 */ /* AK 210891 V1.3 */ { INT i,j; INT dt=0; m_sk_gr(callocobject(),NACHBARLISTE,erg); if (dt) { fprintf(stderr,"m_vector_graph:erg(1)="); fprintln(stderr,erg); } m_il_v(2L,s_gr_s(erg)); if (dt) { fprintf(stderr,"m_vector_graph:erg(2)="); fprintln(stderr,erg); } copy(vector,s_gr_kn(erg)); if (dt) { fprintf(stderr,"m_vector_graph:knotenvector="); fprintln(stderr,s_gr_kn(erg)); } /* die knoten sind die elemente im vector */ m_il_v(s_v_li(vector),s_gr_na(erg)); if (dt) { fprintf(stderr,"m_vector_graph:nachbarschaftsliste="); fprintln(stderr,s_gr_na(erg)); } /* die nachbarschaftsliste hat die laenge des vectors */ for (i=0;i=0 ;i--) { fprintf(texout,"\\put(%d,%d){ \n",s_i_i(s_gr_xkoori(a,i)), s_i_i(s_gr_ykoori(a,i))); tex(s_gr_kni(a,i)); fprintf(texout,"}\n"); } /* nun kommen die verbindungen */ for (i=s_v_li(s_gr_koor(a))-1; i>=0 ;i--) for (j=0; js_v_ii(s_gr_nai(a,i),j)) latex_line( xanfang,yanfang, xende,yende); } fprintf(stderr,"\n\\end{picture}\n"); return OK; } #endif /* GRAPHTRUE */ #ifdef GRAPHTRUE INT latex_line(vonx,vony,nachx,nachy) INT vonx,vony,nachx,nachy; /* latex befehl um line zu zeichen */ /* AK 070291 V1.2 prints to texout instead of stdout */ /* AK 210891 V1.3 */ { fprintf(texout,"\\bezier{%d}",(nachx-vonx)/1000+(nachy-vony)/1000); fprintf(texout,"(%d,%d)",vonx,vony); fprintf(texout,"(%d,%d)", (vonx+nachx)/2, (vony+nachy)/2); fprintf(texout,"(%d,%d)\n",nachx,nachy); return OK; } #endif /* GRAPHTRUE */ /* AK 240603 */ /* routines for the managment of adjacency matrices */ INT add_adjacency_matrix(a,b,c) OP a,b,c; /* AK builds the adjacancy matrix corresponding to the disjoint union of two graphs */ /* AK 240603 */ { INT erg = OK; INT i,j; CTTO(MATRIX,INTEGERMATRIX,"add_adjacency_matrix(1)",a); CTTO(MATRIX,INTEGERMATRIX,"add_adjacency_matrix(2)",b); SYMCHECK(S_M_HI(a) != S_M_LI(a),"add_adjacency_matrix(1):not quadratic"); SYMCHECK(S_M_HI(b) != S_M_LI(b),"add_adjacency_matrix(1):not quadratic"); CE3(a,b,c,add_adjacency_matrix); m_ilih_nm(S_M_HI(a)+S_M_HI(b),S_M_HI(a)+S_M_HI(b),c); for (i=0;i