#include "cdabs.h"

// This file contains some miscellaneous functions


// Function that returns the adjacency which has the given vertex 
// as the source .
Adjacency* Adjacency_Nlist::get_adj(Vertex* vertex)
{
  Adjacency_list_iterator next_arg(*this);
  Adjacency_ each_arg;
  while (each_arg = next_arg())
    if  (each_arg->get_adj(vertex))
      return (each_arg);
  return ((Adjacency*)NULL);
}

int Adjacency::get_adj(Vertex* vertex)
{
  return (source->g_equal(vertex));
}

Vertex* Vertex::cat(Vertex* v)
// Function that reurns a new vertex whose name is a concatenation
//  of the given vertices.
// However if the 2 vertices have the same name return that name
{
  char* char1 = this->get_vertex_name()->get_val();
  char* char2 = v->get_vertex_name()->get_val();
  if (!(strcmp(char1,char2)))
    return (this);
  char* char3 = strcat(char1,"_");
  char* char4 = strcat(char3,char2);
  DemIdent* ret_id = new DemIdent(char4);
  Vertex* ret_vert = new Vertex(ret_id);
  return(ret_vert);
}

char* Adjacency::ns_type()
// Function that returns the type of this Adjacency's neighbor.
{
  return((char *)ns->get_type());
}

Opt_labeled_term* Any_vertex::get_inner()
{
  return NULL;
}

Opt_labeled_term* Optional_term::get_inner()
{
  return (opt->get_inner());
}

