Depth First Search Technique For Rule Based Expert System 1-Issue-4-2014
Depth First Search Technique For Rule Based Expert System 1-Issue-4-2014
ISSN: 2321-8134
IJFEAT
INTERNATIONALJOURNALFORENGINEERINGAPPLICATIONSAND TECHNOLOGY
Depth First Search Technique for Rule Based Expert System
1
B. E. Final Year, Information Technology, JDIET Yavatmal, Maharashtra, India, [email protected]
2
B .E. Final Year, Information Technology, JDIET Yavatmal, Maharashtra, India, [email protected]
3
Asst .Professor, Information Technology, JDIET Yavatmal, Maharashtra, India, [email protected]
Abstract
Depth-first search (DFS) is an algorithm for traversing or searching the tree or graph data structures. Depth-first search is the key
for several of graph or search algorithms. The graph is to be searched is both too large to visit in its entirety or even are not finite,
and DFS may suffer from non-termination when the length of a path in the search tree is infinite. Therefore, the search is only
performed to a limited depth, and due to limited memory availability one usually does not use data structures that keep track of the set
of all previously visited vertices In this case, the time is still linear in the number of expanded vertices and edges. When an
appropriate depth limit is not known a priori, iterative deepening depth-first search applies DFS repeatedly with a sequence of
increasing limits; in the artificial intelligence mode of analysis, with a branching factor more than one, iterative deepening increases
the running time by only a constant factor over the case in which the exact depth limit is known due to the geometric growth of the
number of nodes per level. One starts at the root node and explores as far as possible along with each branch before backtracking.
The Depth First Search is very useful to search problems in Rule Base Expert System Using Depth First Search for Medical
Diagnosis. Depth First Search also lends itself much better to heuristic methods of choosing a likely-looking branch.
Index Terms: Depth-first search, Iterative deepening, Expert system, backtracking, heuristic, etc.
The rule of rule base system is invented in 1970s and they are graph's size is (the number of edges). The number of
used still in used. edges is the degree of a vertex that will be connected to it,
where an edge that connects to the vertex at both ends (a loop)
is counted twice [1].
2. Graph
A directed graph or digraph is an ordered pair D = (V, A) vertices). A graph's size is (the edges).The degree of a
with vertex is the number of edges that connect to it, where an edge
that linked to the vertex at ends (a loop) is counted twice [1].
V a set whose elements are called vertices or nodes,
and
A set of ordered pairs of vertices is called arcs,
4. Algorithms on Graphs
directed edges, or arrows.
y is called head of graph or arc and x is called the tail of We will see a number of algorithms relating to
the arc, if an arc a = (x, y) is considered to be directed from x graphs, generally speaking these falls into two broad
to y; and x is said to be a direct predecessor of y, and y is categories, Depth First Search (DFS) or Breadth First Search
called to be a direct successor of x. If a path starts from x to y, (BFS). Depth First Search and Breadth First Search are
then y is said to be a successor of x and reachable from x, and essentially methods of ordering the vertices of a graph. In a
x is called to be a predecessor of y. real algorithm the vertices would be processed in the
corresponding order, with a call to the processing routine
The arc (y, x) is called the arc (x, y) inverted. If every arc before moving to the next vertex. A vertex which is not live is
in D, the corresponding to inverted arc also belongs to D, called used, or visited. In a Breadth First Search, we label all
directed graph D is called symmetric. A symmetric loop less live neighbors of a vertex before moving on to a new vertex.
directed graph D = (V, A) is similar to a simple undirected In a Depth First Search we move from vertex to live vertex.
graph G = (V, E), where the pairs of inverse arcs in A Depth First Search is a recursive algorithm, Breadth First is
correspond one-to-one with the edges in E; thus the edges in G iterative using a stack. In both cases we start from an initial
number |E| is equal |A|/2, or half the number of arcs in D. vertex, which will be chosen randomly from tree. The order in
which the graph is traversed will depend on the choice of the
initial vertex, does not the algorithm.
3. Tree structure
Both algorithms work on connected components of
A tree structure is a way of representing the
the graph, the algorithm must be restarted with a new initial
hierarchical nature of a structure in a graphical form. It is
vertex for each connected component. Another idea in
named a "tree structure" because the classic representation
algorithms is that of a Greedy Algorithm. In a Greedy
similar to a tree, even though the chart usually upside down
Algorithm we make the locally optimal choice in the hope that
compared to an actual tree, with the "root" at the top and the
this will lead to a globally optimal solution. In most cases this
"leaves" at the bottom.
approach does not work, but it is always worth considering. In
another category entirely we have Random Algorithms. These
A tree structure is the completely conceptual in
algorithms have a random element at every step. The benefit
nature, and appears in several forms, as shown as follows. For
of random algorithms is that they can solve much harder
a discussion of tree structures in specific fields, see Tree given
problems than deterministic algorithms. The downside is that,
below:
there is a chance that neither correct solution will be given nor
Root Node
a chance that the algorithm will returns [2].
http://www.ijfeat.org (C) International Journal For Engineering Applications and Technology [01-04]
February. ISSN: 2321-8134
(b) Gain access to visit the nodes that neighbor the order to reason about such DFS algorithms we have to reason
currently visited node. about a dynamic process what happens and when and such
reasoning is complex. Occasionally, the depth-first forest
The BFS begins at a root node and inspects all the could be introduced in order to provide a static value to aid
neighboring nodes. Then for each of those neighbor nodes in reasoning. We build on this idea. If have an explicit or
turn, it inspects their neighbor nodes which were unvisited, unreserved depth-first forest is good for reasoning then, so
and so on. Compare BFS with corresponding, but more long as the overheads are not very easy to program either
memory efficient Iterative deepening depth-first search and iteratively or recursively provided, we have a suitable
contrast with depth-first search. The breadth-first method computer representation of a graph [4].
always expands an open vertex with the smallest depth. By
this method, the different levels (vertices with the same depth) 4.2.2 DFS Algorithm
of the tree are existed breadth-wise, i.e., only after a level has
been completely visited we go to the next level. From this 1. Place the starting node s on the queue.
method's name comes out. For the exact description, we assign 2. If the queue is empty, return failure and stop.
a so-called depth number to each of the vertices stored in the 3. If the first element on the queue is goal node g, return
database. The breadth-first method chooses the vertex with the success and stop. Otherwise,
smallest depth number to vertex. 4. Remove and expand the first element, and place the
children at the front of the queue (in any order).
4.2 Depth First Search 5. Return to step 2.
Depth-first search (DFS) is an algorithm for Depth first search are performed by dividing
traversing or searching tree or graph data structure. One starts downward into tree as quickly as possible. It does this by
at the root node and explores as far as possible along each always generating a child node from the most recently
branch before backtracking. In the 19th century by French expanded node, then the generating a childs children. And so
mathematician Charles Pierre Trmauxas investigated a until a goal is found or some cutoff depth point d is reached. If
version of depth-first search strategy or algorithm for solving a goal is not found when a leaf node is reached or at the cutoff
mazes. Depth First Search (DFS) is a systematic way of point, the program backtracks to the most recently expanded
visiting the nodes of either a directed or an undirected graph. node and generates another of its children. This process
As with breadth first search DFS have a lot of applications in continues until a goal is found or failure occurs [5].
many problems in Graph Theory. It comprises the main part
of so many graph algorithms. 4.2.3 Example of DFS
Depth-first search or technique of Backtracking has In a depthfirst you keep visiting adjacent nodes until
been widely used for finding solutions to problems in you cant go any further; in other words, you goes deeper and
combinatorial theory and artificial intelligence, but whose deeper into the graph and then back track. In a binary tree, a
properties have not been widely analyzed. There are many depthfirst search (often referred to as depthfirst traversal) is a
ways of searching a graph, depending upon the way in which preorder traversal or search. In a breadthfirst search, the
edges to be selected for searching. Consider the following breadth at a level is traversed before going deeper. There is
rule: when selecting an edge to traverse, always choose an different (no common) breadthfirst traversal in a binary tree.
edge proceeding from the vertex most recently reached which It would mean you would examine all the children before you
still has unexplored edges. A search which uses this rule is examined the childrens children. Consider the following tree
called a depth-first search. The set of old vertices with [6];
possibly unexplored edges may be stored on a stack. Thus a
depth-first search is not acceptable; it is good for
programming [3].
4.2.4 Advantages and Disadvantages of DFS memory requirement is only linear with respect to the search
graph. This is in contrast with breadth-first search which
The advantage of depth-first Search is that memory requires more space. In comparison of breadth first search,
requirement is only linear with respect to the depth first search is more efficient in finding the depth for
searching graph. But breadth-first search is requires medical diagnosis because the depth of the problem is small,
more memory space. so to find the goal state is so simple. So we have used depth
The time complexity of a depth-first Search to depth first technique in rule based expert system.
d is O (b^d) since it generates the same set of nodes
as breadth-first search, but simply not in the similar ACKNOWLEDGEMENT
a order. Thus practically depth-first search is time-
limited rather than space-limited. We would like to thank our, Principal Dr. A. W.
If depth-first search finds solution without exploring Kolhatkar sir for the helpful comments they gave on a
much in a path then the time and space it takes will preliminary draft of this paper. We are also thankful to our
be very less. HOD prof. A. D. Raut and to our all the teaching staff of
department for their help and support. We shall be failing to
Disadvantages of Depth-First Search our duties if we do not express our gratitude to our parents and
friends whose untiring efforts could bring out our success.
The disadvantage of Depth-First Search is that there
is a possibility that it may go down the left-most path References:
forever. Even a infinite tree can generate an finite
graph .To impose a cut off depth on the search is one [1] F. Haiary, Graph Theory, Addison-Wesley, Reading,
of the solution of this problem. Mass., 1969
Depth-First Search is not guaranteed to find the [2] J. Hop croft and R. Tarjan, Efficient algorithms for graph
solution. If more than one solution exists, there is no manipulation, Tech. Rep. 207, Computer Science Department,
guarantee to find minimal solution. Stanford University, Stanford, Calif., 1971.
[3] David J. King, John Launch bury, Structuring Depth-First
5. Conclusion Search Algorithms in Haskell, Department of Computer
Science and Engineering.
[4] Robert Tarjan, Depth-First Search and Linear Graph
Hence we have studied the breadth first search and
Algorithms* Siam J. Comput. Vol. 1, No. 2, June 1972.
depth first search. Depth First Search and Breadth First Search
[5] Dan W. Patterson, Introduction to Artificial Intelligence
are essentially methods of ordering the vertices of a graph. In
and Expert Systems University of Texas EI Paso.
a real algorithm the vertices would be processed in the
corresponding order, with a call to the processing routine [6] Carol Zander,Graphs Introduction and Depthfirst
before moving to the next vertex. Depth-first Search is that algorithm.
http://www.ijfeat.org (C) International Journal For Engineering Applications and Technology [01-04]