001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of AutomataLib, http://www.automatalib.net/. 003 * 004 * AutomataLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * AutomataLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with AutomataLib; if not, see 015 * http://www.gnu.de/documents/lgpl.en.html. 016 */ 017package net.automatalib.graphs.abstractimpl; 018 019import java.util.Iterator; 020 021import net.automatalib.graphs.Graph; 022 023 024public abstract class AbstractGraph<N, E> extends AbstractIndefiniteGraph<N,E> implements Graph<N, E> { 025 026 /** 027 * Provides a realization for {@link Graph#iterator()} relying on 028 * {@link Graph#getNodes()}. 029 * @see Graph#iterator() 030 */ 031 public static <N,E> Iterator<N> iterator(Graph<N,E> $this) { 032 return $this.getNodes().iterator(); 033 } 034 035 /** 036 * Provides a realization for {@link Graph#size()} relying on 037 * {@link Graph#getNodes()}. 038 * @see Graph#size() 039 */ 040 public static <N,E> int size(Graph<N,E> $this) { 041 return $this.getNodes().size(); 042 } 043 044 /* 045 * (non-Javadoc) 046 * @see java.lang.Iterable#iterator() 047 */ 048 @Override 049 public Iterator<N> iterator() { 050 return iterator(this); 051 } 052 053 /* 054 * (non-Javadoc) 055 * @see net.automatalib.graphs.Graph#size() 056 */ 057 @Override 058 public int size() { 059 return size(this); 060 } 061 062 063}