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;
022import net.automatalib.graphs.concepts.NodeIDs;
023
024
025public abstract class AbstractGraph<N, E> extends AbstractIndefiniteGraph<N,E> implements Graph<N, E> {
026        
027        /**
028         * Provides a realization for {@link Graph#iterator()} relying on
029         * {@link Graph#getNodes()}.
030         * @see Graph#iterator()
031         */
032        public static <N,E> Iterator<N> iterator(Graph<N,E> $this) {
033                return $this.getNodes().iterator();
034        }
035        
036        /**
037         * Provides a realization for {@link Graph#size()} relying on
038         * {@link Graph#getNodes()}.
039         * @see Graph#size()
040         */
041        public static <N,E> int size(Graph<N,E> $this) {
042                return $this.getNodes().size();
043        }
044        
045        public static <N,E> NodeIDs<N> nodeIDs(Graph<N,E> $this) {
046                return new SimpleNodeIDs<>($this);
047        }
048
049        /*
050         * (non-Javadoc)
051         * @see java.lang.Iterable#iterator()
052         */
053        @Override
054        public Iterator<N> iterator() {
055                return iterator(this);
056        }
057
058        /*
059         * (non-Javadoc)
060         * @see net.automatalib.graphs.Graph#size()
061         */
062        @Override
063        public int size() {
064                return size(this);
065        }
066
067        /* (non-Javadoc)
068         * @see net.automatalib.graphs.Graph#nodeIDs()
069         */
070        @Override
071        public NodeIDs<N> nodeIDs() {
072                return nodeIDs(this);
073        }
074        
075        
076
077
078}