Source Code Cross Referenced for GraphProcessor.java in  » Code-Analyzer » classycle » classycle » graph » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » classycle » classycle.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2003-2008, Franz-Josef Elmer, All rights reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         * - Redistributions of source code must retain the above copyright notice, 
008:         *   this list of conditions and the following disclaimer.
009:         * - Redistributions in binary form must reproduce the above copyright notice, 
010:         *   this list of conditions and the following disclaimer in the documentation 
011:         *   and/or other materials provided with the distribution.
012:         *
013:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
014:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
015:         * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
016:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
017:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
018:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
019:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
020:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
021:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
022:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
023:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
024:         */
025:        package classycle.graph;
026:
027:        /**
028:         *  Abstract class for all algorithms based on deep search first.
029:         *  This class is designed in accordance with the Template Method pattern.
030:         *  The basic algorithm (implemented in the method
031:         *  {@link #process}) reads:
032:         *  <pre>
033:         *    vertex.visit();
034:         *    processBefore(vertex);
035:         *    for (int i = 0, n = vertex.getNumberOfOutgoingArcs(); i &lt; n; i++) {
036:         *      processArc(vertex, vertex.getHeadVertex(i));
037:         *    }
038:         *    processAfter(vertex);
039:         *  </pre>
040:         *  The methods {@link #initializeProcessing initializeProcessing()}, 
041:         *  {@link #processBefore processBefore()},
042:         *  {@link #processArc processArc()}, and 
043:         *  {@link #processAfter processAfter()} have to be implemented
044:         *  by concrete classes.
045:         *  <p>
046:         *  The class will be used by creating an instance and invoking
047:         *  {@link #deepSearchFirst deepSearchFirst()} one or several times. 
048:         *  Either the graph will be
049:         *  modified or some result objects are created which can be obtained
050:         *  by special methods defined in concrete subclasses. Note, that
051:         *  a <tt>GraphProcessor</tt> is not thread-safe.
052:         *
053:         *  @author Franz-Josef Elmer
054:         */
055:        public abstract class GraphProcessor {
056:            /**
057:             *  Performs a deep search first of the specified graph.
058:             *  First, processing will be initialized and all vertices of the graph
059:             *  will be reset. Then for all unvisited vertices the
060:             *  method <tt>process(Vertex)</tt> will be invoked. At last,
061:             *  processing will be finished.
062:             *  @param graph A directed graph.
063:             */
064:            public void deepSearchFirst(Vertex[] graph) {
065:                initializeProcessing(graph);
066:                for (int i = 0; i < graph.length; i++) {
067:                    graph[i].reset();
068:                }
069:
070:                for (int i = 0; i < graph.length; i++) {
071:                    if (!graph[i].isVisited()) {
072:                        process(graph[i]);
073:                    }
074:                }
075:                finishProcessing(graph);
076:            }
077:
078:            /** Processes the specified vertex. */
079:            protected void process(Vertex vertex) {
080:                vertex.visit();
081:                processBefore(vertex);
082:                for (int i = 0, n = vertex.getNumberOfOutgoingArcs(); i < n; i++) {
083:                    processArc(vertex, vertex.getHeadVertex(i));
084:                }
085:                processAfter(vertex);
086:            }
087:
088:            /**
089:             *  Initializes processing. Will be called in method
090:             *  {@link #deepSearchFirst}.
091:             */
092:            protected abstract void initializeProcessing(Vertex[] graph);
093:
094:            /**
095:             *  Processes the specified vertex before its outgoing arcs are processed.
096:             *  @param vertex Vertex to be processed.
097:             */
098:            protected abstract void processBefore(Vertex vertex);
099:
100:            /**
101:             *  Processes the arc specified by tail and head vertices.
102:             *  @param tail Tail vertex of the arc.
103:             *  @param head Head vertex of the arc.
104:             */
105:            protected abstract void processArc(Vertex tail, Vertex head);
106:
107:            /**
108:             *  Processes the specified vertex after its arcs have been processed.
109:             *  @param vertex Vertex to be processed.
110:             */
111:            protected abstract void processAfter(Vertex vertex);
112:
113:            /**
114:             *  Finishes processing.  Will be called in method
115:             *  {@link #deepSearchFirst}.
116:             */
117:            protected abstract void finishProcessing(Vertex[] graph);
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.