JPH02151971A - Method for searching node of tree structure data - Google Patents

Method for searching node of tree structure data

Info

Publication number
JPH02151971A
JPH02151971A JP63306073A JP30607388A JPH02151971A JP H02151971 A JPH02151971 A JP H02151971A JP 63306073 A JP63306073 A JP 63306073A JP 30607388 A JP30607388 A JP 30607388A JP H02151971 A JPH02151971 A JP H02151971A
Authority
JP
Japan
Prior art keywords
node
address
data
tree
child
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP63306073A
Other languages
Japanese (ja)
Inventor
Tadashi Hirose
広瀬 正
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP63306073A priority Critical patent/JPH02151971A/en
Publication of JPH02151971A publication Critical patent/JPH02151971A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

PURPOSE:To rapidly execute node search without saving addresses and to rapidly decide the existence of a loop by holding a succeeding node address necessary for node search in each node. CONSTITUTION:A node value expressing an applied tree structure data and a slave node address are set up on a prescribed position of a node information area. Then, the search order of the tree structure data is determined and the succeeding node address is set up in a prescribed position of the node information area. When a slave node address is not set up, the succeeding node address is used to successively refer respective node information of n-advanced three structure data. Consequently, address stacking at the time of searching nodes is omitted and the existence of a loop existing in the tree structure data is efficiently detected.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は、木構造データの表現および処理の方法に係り
、特にパターンマチング処理などに要する木構造データ
のノード探索に好適な処理方法に関する。
[Detailed Description of the Invention] [Industrial Application Field] The present invention relates to a method for representing and processing tree-structured data, and particularly relates to a processing method suitable for node searching of tree-structured data required for pattern matching processing. .

〔従来の技術〕[Conventional technology]

非数値処理分野で取り扱うデータ構造の中で。 Among the data structures handled in non-numerical processing fields.

頻繁に用いられるデータ構造に木構造データがある。こ
こで、木構造データとは、ノード情報の集合をいう。ノ
ード情報には、そのノードの値(ノード値)と、そのノ
ードと別のノード(子ノード)との関係を示す情報を含
む。各木構造データにはそのデータを代表するノード(
ルートノードと呼ぶ)が決められている。
Tree-structured data is a frequently used data structure. Here, the tree structure data refers to a set of node information. The node information includes information indicating the value of the node (node value) and the relationship between the node and another node (child node). Each tree-structured data has a node (
(referred to as the root node) is determined.

この木構造データに対する基本的な処理は、各ノードの
ノード値を深さ優先順に取り出す処理であり、ノード探
索処理と呼ばれる。たとえば、2つの木構造データのパ
ターン−数比較を行なう場合を考える。すべてのノード
値が同一かあるいは少なくとも一方が[申](任意の値
を許すという表示、値は構造データであっても良い)の
場合、2つの木構造データはパターン一致しているとす
る。へ′ターン一致比較を行なうには2つの木構造デー
タのそれぞれに対してノード探索処理を行なわねばなら
ない。
The basic process for this tree-structured data is a process of extracting the node value of each node in order of depth priority, and is called a node search process. For example, consider a case where a pattern-number comparison of two tree-structured data is performed. If all the node values are the same or at least one is [mon] (indication that any value is allowed; the value may be structured data), the two tree-structured data are considered to have a pattern match. In order to perform a turn matching comparison, node search processing must be performed on each of the two tree-structured data.

第2図に木構造データの例を示す。上述のへ′ターン一
致の定義に従えば、同図(a)の木構造データは同図(
)))、(Q)とパターン一致しないが、同図(d)と
はパターン一致する。(a)と(b)とは構造が不一致
であり、(a)と(c)とはノード値(上から4番目の
レベルの左から2番目のノード値c、m)が不一致だか
らである。
Figure 2 shows an example of tree-structured data. According to the above-mentioned definition of he'turn matching, the tree structure data in figure (a) becomes (
))), the pattern does not match with (Q), but the pattern matches with (d) in the same figure. This is because (a) and (b) have mismatched structures, and (a) and (c) have mismatched node values (the second node values c and m from the left on the fourth level from the top). .

従来の木構造データのメモリ上でのデータ表現方法、特
に木構造データのパターン−数比較に適したデータ表現
は、デーニーアイ、リサーチレポートNα、39(19
77)の第36頁から第44頁(D、A、] 。
Conventional data representation methods in memory for tree-structured data, particularly data representations suitable for pattern-number comparison of tree-structured data, are described in Danii, Research Report Nα, 39 (19
77), pages 36 to 44 (D, A,].

−Reaearch Report Nn、39(19
77)pp、:(6−4/I、 I)、11.l)。
-Reasearch Report Nn, 39 (19
77) pp, :(6-4/I, I), 11. l).

Warren著: Impl、ementinF、PR
OLOG−compj Hngpredicate l
ogic programs Volume])におい
て論じられている。第3図に、第2図(a)に示した木
構造データを上記従来方法で表現した回を示す3゜n個
の子ノードを持つノードをn + 1個の連続したセル
(メモリ要素)の並びで表わす。各セルは「タグフィー
ルド」と[内容フィールド」から構成され、タグフィー
ルドのlF+ 、  IAI 、  II]1はそれぞ
れのセルが「ファンフタセル」、「ア1ヘムセル」、「
アドレスセル」であること、すなわち、それぞれ内容フ
ィールドの値がr子ノードを持つノードのノード値」、
「子ノードを持たないノードのノード値」、[子ノード
を表わすセルの格納アドレス」であることを示す。この
データ表現方法を以下1−り一型表現と呼ぶ。
Written by Warren: Impl, ementinF, PR
OLOG-compj Hngpredicate l
ologic programs Volume]). Figure 3 shows how the tree-structured data shown in Figure 2(a) is expressed using the conventional method.3゜A node with n child nodes is divided into n + 1 consecutive cells (memory elements). It is expressed as a sequence of Each cell is composed of a "tag field" and a [content field], and the tag fields IF+, IAI, II]1 are "Fanfuta cell", "A1 hem cell", "
``address cell'', i.e. the value of each content field is the node value of a node with r child nodes'',
Indicates that it is a "node value of a node that does not have a child node" and a "storage address of a cell representing a child node." This data representation method is hereinafter referred to as 1-type representation.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

トリー型テータ表現には2つの問題点がある。 There are two problems with the tree-type theta representation.

第]−の問題点は、ノード探索処理時に、次に調べるべ
きセルのアドレスを順次記憶していく必要がある点であ
る。例えば第3図の場合、ノードgを調べる前にノード
aのセルのアドレスを、さらにノードhを調べる白11
にノード°pの指すセルのアドレスを記憶する必要があ
る。このアドレスの記憶処理をアドレススクッキングと
呼ぶ。
The problem with this method is that during the node search process, it is necessary to sequentially store the addresses of the cells to be checked next. For example, in the case of FIG. 3, before checking node g, White 11 checks the cell address of node a, and then checks node h.
It is necessary to store the address of the cell pointed to by node °p. This address storage process is called address scooking.

トリー型テータ表現の第2の問題点は、木構造データ内
に存在する内部ループを効率良く検知できない点である
。たとえば、第4図に示す木構造データは内部にループ
を含む。このループの存在を検知しなければ、ノード探
索処理は無限ループに陥る。従来のデータ表現を用いて
木構造データを表現した場合、ループの存在を検知する
ためには過去に探索したノード(祖先ノード)のアドレ
スをすべて記憶しておき、新たなノードを探索する毎に
、そのノードのアドレスがすでに記憶されている祖先ノ
ードのアドレス群のなかに存在するか否かを調べねばな
らない。
The second problem with the tree-type theta representation is that internal loops existing in tree-structured data cannot be efficiently detected. For example, the tree structure data shown in FIG. 4 includes an internal loop. If the existence of this loop is not detected, the node search process will fall into an infinite loop. When representing tree-structured data using conventional data representation, in order to detect the existence of a loop, all addresses of nodes searched in the past (ancestor nodes) are memorized, and each time a new node is searched, , it is necessary to check whether the address of the node exists in the already stored address group of ancestor nodes.

木構造データの探索方式の別の従来例として特開昭58
−3035r木構造情報探索制御方式」がある。
Another conventional example of a search method for tree-structured data is JP-A-58.
-3035r tree structure information search control method".

この方式は木構造データに対する過去の探索経過を木構
造内に記憶させる方式である。
This method is a method in which past search progress for tree-structured data is stored within the tree structure.

本発明の目的は、前述の従来方法の第1の問題点、すな
わち、ノード探索時のアドレススクッキングを不要とす
ることにある。
An object of the present invention is to solve the first problem of the conventional method described above, that is, to eliminate the need for address scooking when searching for a node.

本発明の他の目的は、木構造データ内に存在するループ
の存在を効率良く検出することにある。
Another object of the present invention is to efficiently detect the presence of loops in tree-structured data.

〔課題を解決するための手段〕[Means to solve the problem]

上記目的を達成するため、各ノードに対応するノード情
報に、次に探索すべきノードのアドレス(次ノードアド
レス)を持たせるデータ表現方法を導入する。この表現
方法は、従来にない表現方法であり、以下、ネットワー
ク型データ表現と呼ぶ。
In order to achieve the above object, a data representation method is introduced in which the node information corresponding to each node includes the address of the next node to be searched (next node address). This representation method is a non-conventional representation method, and will hereinafter be referred to as network-type data representation.

この点において、上記特開昭58−3035と全く異な
る。
In this respect, it is completely different from the above-mentioned Japanese Patent Application Laid-Open No. 58-3035.

ネットワーク型データ表現用いる場合、木構造データを
メモリ」二に格納する時点で、上記次ノードアドレスを
各ノードのデータとして設定しておく。次ノードアドレ
スには常に次に探索すべきアドレスが設定されているの
で、従来方法におけるアドレススクッキングは不要とな
る。ただし、この方法は、内部ループなど、木構造デー
タの異なる二つの部分に存在する同じデータ構造(木構
造データ強いて言えば、部分木構造データ)を一つのデ
ータ表現で共用して表現しない場合に適用できる。
When using network type data representation, the above-mentioned next node address is set as data for each node at the time the tree structure data is stored in the memory. Since the next node address is always set to the address to be searched next, address scooking in the conventional method is no longer necessary. However, this method is useful when the same data structure that exists in two different parts of tree-structured data (tree-structured data, more specifically, subtree-structured data) cannot be expressed in a single data representation, such as in an inner loop. Applicable.

木構造データの異なる二つの部分に存在する同じデータ
構造(木構造データ)を一つのデータ表現で共用して表
型、する場合(内部にループが存在する場合はこの場合
に含まれる)、木構造データをメモリ上に格納する時点
で、次ノードアドレスを設定しておくことができないが
、ノード探索時点で設定することにより、同等の効果を
得ることが出来る。
When the same data structure (tree-structured data) that exists in two different parts of tree-structured data is shared in one data representation to form a table (this includes cases where there is a loop inside), the tree-structured data Although it is not possible to set the next node address at the time of storing the structural data on the memory, the same effect can be obtained by setting it at the time of node search.

〔作用〕[Effect]

ネットワーク型データ表型1において、各ノード情報に
格納される情報を第5図に示″lo木図は、第2図の木
構造データを表現した場合を表している。図中の丸(0
)がノードを表わし、そのなかの値がノード値である。
The information stored in each node information in network type data table type 1 is shown in Figure 5. The lo tree diagram represents the case where the tree structure data in Figure 2 is expressed.
) represents a node, and the value inside is the node value.

点線の丸(○)は仮想的−に新たに設定したノード探索
の終わりを示すノード(終端ノード)である。終端ノー
1くのノード値はrendJとしておく。
The dotted circle (○) is a node (terminal node) that virtually indicates the end of the newly set node search. The node value of the terminal node 1 is set to rendJ.

図中の矢印(→)は、それぞれの矢印の根元のノードの
ノード情報に格納される子ノードアドレス情報、次ノー
ドアドレス情報を示す。矢印のなかで、細線矢印は従来
のトリー型テータ表現がメモリ上に格納していた情報で
ある。ネットワーク型表現は、この情報に加えて太線矢
印の情報をノード情報内に格納することができる。
Arrows (→) in the figure indicate child node address information and next node address information stored in the node information of the node at the root of each arrow. Among the arrows, the thin arrows represent information stored in memory in the conventional tree-type theta representation. In addition to this information, the network type representation can store bold arrow information in the node information.

第1図に、より具体的なネットワーク型データ表現の例
を示す。n個の子ノードを持つノードのノード情報をn
 千2個のセルの並びで表わす。並び順を、白ノードの
ノード値を示すセル、第1子ノードから第n子ノードを
示すセル、次ノードを示すセルの順序にしておくと、子
ノードの探索手順と、次ノードの探索手順を[隣接する
セルを取り出し、もしそのセルがアドレスを示すセルな
ら、そのアドレスの位置にあるセルを取り出すJという
単一かつ単純な処理手順(以下、新デレファレンス処理
手順と呼ぶ)で実現できる。
FIG. 1 shows a more specific example of network data representation. The node information of a node with n child nodes is
It is expressed as a sequence of 1,000 and 2 cells. By arranging the cells in the order of cells indicating the node value of the white node, cells indicating the first to nth child nodes, and cells indicating the next node, the child node search procedure and the next node search procedure can be realized by a single and simple processing procedure (hereinafter referred to as the new dereference processing procedure) that extracts the adjacent cell and, if that cell indicates an address, extracts the cell at the location of that address. .

ネットワーク型データ表現は次ノードアドレスをノード
に対応させて記憶しておけるから、木構造データの異な
る二つの部分に存在する同じデータ構造(木構造データ
)を一つのデータ表現で共用して表現しない場合は、−
旦設定した次ノードアドレスを繰返し使用できる。これ
がネットワーク型データ表現を用いることから得られる
第一の利点である。例えば木構造データを取り扱う記号
処理言語1)l(OL OGの処理系を実現する場合、
ブロクラム頭部の仮引数の木構造データをネットワーク
型データ表現にしておけば、述語呼出し毎に仮引数の木
構造データのノード探索のためにア1くレススタッキン
グを行なわなくて良い。
Network-type data representation allows the next node address to be stored in correspondence with the node, so the same data structure (tree-structured data) that exists in two different parts of tree-structured data is not shared and expressed in one data representation. If -
The next node address once set can be used repeatedly. This is the first advantage derived from using network-based data representation. For example, when implementing a symbolic processing language 1) that handles tree-structured data (OL OG processing system,
If the tree-structured data of the formal argument in the block head is expressed as network data, there is no need to perform address stacking to search for nodes in the tree-structured data of the formal argument every time the predicate is called.

現在探索中のセルのアドレスをpとすると、「pに隣接
するセルのアドレスを求めろrpJの指すセルの種別を
判定するJというニー〕の処理だけから成る。、従来の
探索処理が子ノードの個数の判定やスタックに退避した
アドレスの回復処理などが必要であったのに比べて非常
にm純な処理でノード探索処理が実現できる。
Assuming that the address of the cell currently being searched is p, it consists only of the following process: ``Find the address of the cell adjacent to p.Determine the type of cell pointed to by rpJ.'' The conventional search process The node search process can be realized with extremely simple processing compared to the case where it was necessary to determine the number of addresses and to recover the addresses saved in the stack.

ネットワーク型データ表現を用いることの第Fの利点は
、本表現はそのまま従来の1〜り一型データ表現として
も解釈できる点である。従来のトリー型テータ表現(第
2図)とネットワーク型データ表現(第1図)の相違は
、前者がT】個の子ノードを持つノードをn−1−1−
個のセルの並びで表わしているのに対し、後者がn+2
個のセルの並びで表わしている点でだけである。しかも
、n +2個のセルのうちのn+1個目までは内容が同
一である。したがって、n +2個目のセルを無視すれ
ば従来のトリー型データ表現として取り扱うことが出来
る。この利点は、次に述べる第四の利点を生む前提であ
ると同じに、後に述べるネットワーク型データ表現の欠
点を緩和する役割を持つ。
The Fth advantage of using the network type data representation is that this representation can be interpreted as it is as a conventional 1-1 type data representation. The difference between the conventional tree-type data representation (Fig. 2) and the network-type data representation (Fig. 1) is that the former represents a node with T] child nodes as n-1-1-
While the latter is represented by a row of n+2 cells,
It is only a point that is represented by a sequence of cells. Furthermore, the contents are the same up to the (n+1)th cell among the (n+2) cells. Therefore, if the (n+2)th cell is ignored, it can be handled as a conventional tree-type data representation. This advantage is the premise for producing the fourth advantage described below, and also has the role of alleviating the disadvantages of network-type data representation described later.

木構造データの内部に存在するループを検出するために
は、探索中の親ノードを再訪したかどうかを調べる必要
がある。ネットワーク型データ表現では次ノードアドレ
スの表現エリアをノードに対応させて記憶するが、探索
先のノードに既に次ノードアドレスが設定されていれば
、親ノードへの再訪である。したがって、探索先のノー
ドに次ノードアドレスが設定されているか否かを判定す
ることにより、内部にループが存在していたかどうかが
判る。これがネツ1−ワーク型データ表現を用いること
から得られる第四の利点である。
In order to detect loops that exist within tree-structured data, it is necessary to check whether the parent node being searched has been revisited. In network-type data representation, the next node address representation area is stored in association with the node, but if the next node address has already been set for the node to be searched for, the parent node is revisited. Therefore, by determining whether or not the next node address is set in the search destination node, it is possible to determine whether or not there is an internal loop. This is the fourth advantage derived from using a network type data representation.

たとえば、第6図に示す木構造データを考える。For example, consider the tree structure data shown in FIG.

ルートノード(ノードf)から辿るとき、ノード11の
第2子ノードがループしている。ノード探索時に、その
ノードの次ノードアドレスを設定し、探索終了時に消去
しておく。ノードhからノードfを探索にゆくときノー
ドfの次ノードアドレスが消去されていないので、ルー
プの存在が判る。
When tracing from the root node (node f), the second child node of node 11 is looped. When searching for a node, set the next node address for that node, and delete it when the search ends. When searching for node f from node h, the existence of a loop is known because the next node address of node f is not erased.

ネットワークをデータ表現の第1の欠点はトリー型デー
タ表現よりもメモリ消″#量か多い点であるが、近年の
メモリ容量の拡大とデータキャッシュ機構の発達により
、この欠点は実現」二の障害と−ならなくなった。
The first drawback of network data representation is that it consumes more memory than tree-type data representation, but with the recent expansion of memory capacity and the development of data cache mechanisms, this drawback has been overcome. It no longer becomes -.

ネットワーク型データ表現の第2の欠点は、本構造デー
タの異なる二つの部分に存在する同じデータ構造(木構
造データ)を一つのデータ表現で共用して表現すること
ができない点である。しかし、第3の利点で述べたよう
に、ネットワーク型表現はトリー表現を完全に包含した
表現であることから、ネットワーク型データ表現をトリ
ー型データ表現として扱う処理部分をdQけることによ
り、実用上の問題とはならない。
The second drawback of the network-type data representation is that the same data structure (tree-structured data) existing in two different parts of the main structural data cannot be shared and represented in one data representation. However, as mentioned in the third advantage, since the network type representation is an expression that completely includes the tree type data representation, by subtracting the processing part that handles the network type data representation as the tree type data representation, it is possible to This is not a problem.

たとえば、第2図(8)の木構造データは、ノードル以
下の部分木が同じ41 M’iをしている。この部分木
を一つのデータ表現を共用して表現すると、第7図のよ
うになる。図中、斜線のセル(次ノードセル)は、この
木構造データ生成時に設定出来ない。しかし、このデー
タをトリー型データ表現として不都合なく扱える。
For example, in the tree structure data shown in FIG. 2 (8), the subtrees below the node have the same number of 41 M'i. When this subtree is expressed using a single data representation, it becomes as shown in FIG. In the figure, cells with diagonal lines (next node cells) cannot be set when generating this tree structure data. However, this data can be handled as a tree-type data representation without any inconvenience.

PItOLOG処理系において、ブロクラム内に含まれ
る木構造データにはループの存在が許されない。
In the PItOLOG processing system, the existence of loops is not allowed in tree-structured data included in a blockrum.

そこで、ネットワーク型データ表現し、第1の利点を生
かした高速化を実現する。一方、パターンマツチング処
理されるデータは部分木の共用が発生する可能性がある
ので、ネジ1−ワータデ−−タ表現を従来のトリー型デ
ータ表現として処理する。
Therefore, network-type data representation is used to achieve high speed by taking advantage of the first advantage. On the other hand, since there is a possibility that shared subtrees may occur in data subjected to pattern matching processing, the screw 1-water data representation is processed as a conventional tree-type data representation.

さらにこのデータをプログラムとして登録するとき、第
4の利点を生かしながら内部ループが存在しないことを
調べ、各ノードの次ノードアドレスを設定し完全なネッ
トワーク型データ表現にする。
Furthermore, when registering this data as a program, it is checked that there are no internal loops, taking advantage of the fourth advantage, and the next node address of each node is set to create a complete network-type data representation.

〔実施例〕〔Example〕

以下、本発明の実施例を図面を用いて説明する。 Embodiments of the present invention will be described below with reference to the drawings.

第1図は本発明に基づく処理フローを示す。説明をより
具体的にするために、本発明による処理の対象を次に示
す木構造データとする。
FIG. 1 shows a processing flow based on the present invention. In order to make the explanation more concrete, the following tree structure data will be processed by the present invention.

fk(h(b、c+ d) + P(e、 1.)) 
l a、 g(、j+ P(e+ 1)))この木構造
データは、第2図(a)の木構造を示す。すなわち、ノ
ードy、ノードZを子ノードと持つノードXがある場合
、それらの構造をx (y +2)と表わしているもの
である。
fk(h(b, c+ d) + P(e, 1.))
l a, g(, j+ P(e+ 1))) This tree structure data shows the tree structure shown in FIG. 2(a). That is, if there is a node X having node y and node Z as child nodes, their structure is expressed as x (y +2).

上記の木構造データを第1図130に示すようなノード
情報として表わす6ノード情報は各ノード毎にn個の子
ノードを持つときn +2個のセルの並びで表わす。た
とえばノードfは子ノードとして、g+au gの3ノ
ードを持つので、5個のセルの並びで、そのノード情報
が表される。
Six node information representing the above tree structure data as node information as shown in FIG. 1 130 is represented by an array of n+2 cells when each node has n child nodes. For example, node f has three nodes g+au g as child nodes, so the node information is represented by a sequence of five cells.

ステップ100において、以上説明した如く、ノード情
報が設定される。ノード情報の先頭のセルは、タグフィ
ールドをFとし、内容フィールドにノードの値とそのノ
ードが持つ子ノードの数が設定される。たとえば、ノー
ドfに関して、111−/3”と設定される。2番目か
らn+1番目のセルには、子ノードの値か子ノードのノ
ード情報エリアのアドレスが設定される。子ノーIくが
さらに子ノードを持たない場合に、子ノード値がau定
される。そのときタグフィールドはAである。たとえば
、ノードfにおいて、その子ノードaはさらに子ノード
を持たないので、タグフィールドをAとし、内容フィー
ルドにaが設定される。一方、子ノードがさらに子ノー
ドを持つ場合には、子ノードのノード情報エリアの先頭
アドレス(子ノードアドレス)が設定される。たとえば
ノードfのノード情報エリアの2番目のセルには、その
タグフィールドにPを設定し、内容フィールドに子ノー
ドであるノードgのノード情報エリアの先頭アドレスを
設定する。
In step 100, node information is set as explained above. In the first cell of the node information, the tag field is set to F, and the content field is set to the value of the node and the number of child nodes that the node has. For example, regarding node f, it is set as 111-/3''. The value of the child node or the address of the node information area of the child node is set in the second to n+1 cells. When there is no child node, the child node value is set as au.In that case, the tag field is A.For example, in node f, its child node a does not have any child nodes, so the tag field is set to A, "a" is set in the content field.On the other hand, if the child node has further child nodes, the start address (child node address) of the node information area of the child node is set.For example, the start address (child node address) of the node information area of node f is set. In the second cell, P is set in its tag field, and the start address of the node information area of node g, which is a child node, is set in its content field.

また、子ノードのアドレスを1つも持たないノード情報
エリアの場合にはn+1番目のセルには。
In addition, in the case of a node information area that does not have any child node address, the (n+1)th cell.

探索すべき次ノードのノード情報エリアの未探索セルの
アドレスを設定する。
Set the address of the unsearched cell in the node information area of the next node to be searched.

次にステップ110において、木構造データの探索順序
を決定し、その順序に基づいた次ノードアドレスをノー
ド情報エリアの所定位置に設定する。第1図には130
で示される木構造を左優先で探索する場合の順序を適用
した場合の次ノードアドレスを各ノード情報エリアのn
+1番目のセル(最後尾のセル)に設定した様子を14
0に示す。なお、各ノード情報エリアの先頭セルからn
+1番目のセルに斜線を施しであるのは、図の繁雑化を
避けるためであり、その部分は130と同じである。本
ステップでは探索順序は左優先であっても、何であって
も良い、すなわち従来技術で′良く、本ステップの本発
明を特徴付けることは探索手順に基づいた次ノードアド
レスをノード情報エリアの最後尾セルに設定することに
ある。なお、探索の最後になるノードの最後尾セルには
endを設定する。
Next, in step 110, the search order of the tree structure data is determined, and the next node address based on the order is set at a predetermined position in the node information area. Figure 1 shows 130
n of each node information area when applying the left-first search order for the tree structure shown in
14 shows how it is set in +1st cell (last cell)
0. In addition, n from the first cell of each node information area
The reason why the +1st cell is shaded is to avoid complication of the diagram, and that part is the same as 130. In this step, the search order may be left-first or in any other order.In other words, the prior art may be sufficient.What characterizes the present invention in this step is that the next node address based on the search procedure is placed at the end of the node information area. It is to set it in the cell. Note that end is set in the last cell of the node that is the last node in the search.

ステップ120では、ノード情報エリアの子ノードアド
レスに加えて、ステップ110′″C−設定した次ノー
ドアドレスを用いて各ノード情報を探索する。その手順
を具体的に説明する。まず、ノードfの2番目のセルに
ノードにのノード情報エリアのアドレスが設定されてい
るので、ノードにの探索に移る。ノードgのノー1〜情
報エリアの2番目のセルにノードhのノード情報エリア
のアドレスが設定されているので、ノードhの探索に移
る。
In step 120, in addition to the child node address in the node information area, the next node address set in step 110'''C is used to search for information on each node. Since the address of the node information area of the node is set in the second cell, we move on to searching for the node.The address of the node information area of node h is set in the second cell of the No. 1 to information area of node g. Since it has been set, we move on to searching for node h.

ノードhのノード情報エリアの第2〜4番[1のセルに
は、各々b、c、dのノード値が設定されているので、
これらの値を順次探索する。次に第5番目(最後尾)セ
ルには、次ノードアドレスとしてノーFPのノード情報
エリアのアドレスが設定されているので、ノードPの探
索に移る。ノードPの第2,3番目のセルを探索した後
、最後尾のセルにはノードfのノード情報エリアの第3
番目のセルのアドレスが設定されているので、ノードf
の子ノードaの探索に移る。ノードaの探索の後、ノー
ドK(第1図130又は140の中にノードgが2つあ
り、その右方のノードg)の探索に移る。以上のように
探索すると、第1図最下に記しである如く出力、ノー1
く値の列を得ることができる。
Cells 2 to 4 [1 in the node information area of node h have the node values b, c, and d set respectively, so
Search these values sequentially. Next, in the fifth (last) cell, the address of the node information area of no FP is set as the next node address, so the search for node P is started. After searching the second and third cells of node P, the last cell has the third cell of node information area of node f.
Since the address of the th cell is set, the node f
Let's move on to searching for child node a. After searching for node a, the search moves on to node K (there are two nodes g in 130 or 140 in FIG. 1, and the node g on the right side). When searching as above, the output is No. 1 as shown at the bottom of Figure 1.
You can get a sequence of values.

以上の説明で次のような場合が抜けている。たとえば、
第1図中の左方のノードgの最後尾セルに設定されてい
るアドレスを用いていない点である。この点は、後で第
12図を用いて説明するノード値が変数(不定)である
場合に、本発明に基づく探索を、木構造のパターンマツ
チングに用いるとき利用される。すなわちノードgにお
いて、ノードhおよびノードPの探索を、パターンマツ
チングの相手(対象)となる木構造がら、不要とする場
合に利用される。
The following cases are omitted from the above explanation. for example,
The point is that the address set in the last cell of node g on the left in FIG. 1 is not used. This point is utilized when the search based on the present invention is used for pattern matching of a tree structure when the node value, which will be explained later using FIG. 12, is a variable (indeterminate). That is, it is used when node g makes it unnecessary to search for node h and node P in the tree structure that is the partner (target) of pattern matching.

また、ステップ110の処理が全ノードに関して終了し
た後、ステップ120の処理に入るように説明したが、
各ノード毎にステップ110、ステップ120を繰り返
しても良い。すなわち、あるノードに関して次ノードア
ドレスを設定し、その設定した次ノードの探索に移る方
法である。
Furthermore, although it has been explained that the process of step 120 is started after the process of step 110 is completed for all nodes,
Steps 110 and 120 may be repeated for each node. That is, this is a method of setting a next node address for a certain node and moving on to searching for the set next node.

以下、本発明を構造パターン検索システムおよびpro
log言語処理系に適用した場合の実施例を説明する。
Hereinafter, the present invention will be described as a structural pattern search system and a pro
An example in which the present invention is applied to a log language processing system will be described.

第8図は、木構造パターン検察システlへ計算機システ
ム上に構築した場合のブロック構成図である。
FIG. 8 is a block diagram of the tree structure pattern investigation system I constructed on a computer system.

計算機11は、キーボードI 3から入力される入力デ
ータ(ループを含まない木構造データ)と一致するパタ
ーンデータを探し、デイスプレィ装置12に出力する。
The computer 11 searches for pattern data that matches the input data (tree structure data not including loops) input from the keyboard I 3 and outputs it to the display device 12 .

計算機11には、入出カプログラム14、変換プロゲラ
l\15、制御プログラム16、パターンマツチングプ
ログラム17と入カテ゛−タエリア22とパターンデー
タエリア19が設けられる。
The computer 11 is provided with an input/output program 14, a conversion programmer 15, a control program 16, a pattern matching program 17, an input category area 22, and a pattern data area 19.

パターンデータエリア19内には、複数のパターンデー
タ21と、それらの先頭アドレスを格納するパターンデ
ータテーブル20が存在する。図中の破線矢印は制御の
流れを、実線矢印はデータの流れを示す。キーボード1
3からデータが入力されると、入出カプログラA i 
4は変換プログラムに入力データを渡す。変換プログラ
ム15は入力データをネットワーク型表現に変換して入
力データエリア18内に格納する。このとき次ノードア
ドレスは静的に設定する。静的に設定とは第1回のステ
ップ100における設定に同様である。次に入出カプロ
グラム14は制御プロゲラ1116を起動する。制御プ
ログラム16はバタ・−ンデータテーブル20から順次
1つずつパターンデータの先頭アドレスを取り出し、パ
ターンマツチングプログラムに渡す。パターンデータ2
J−はそれぞれあらかじめネットワーク型表現に変換さ
れてバタ−ンデータエリア19に格納されている。(次
ノードアドレスも設定済である。)パターンマツチング
プログラム17は人力データ22と制御プログラム16
から指示されたパターンデータ21の′中の1つとのマ
ツチング処理を行なう。
In the pattern data area 19, there are a plurality of pattern data 21 and a pattern data table 20 that stores their start addresses. The dashed arrows in the figure indicate the flow of control, and the solid arrows indicate the flow of data. keyboard 1
When data is input from 3, input/output coupler A i
4 passes the input data to the conversion program. The conversion program 15 converts the input data into a network type representation and stores it in the input data area 18. At this time, the next node address is statically set. Static setting is the same as the setting in step 100 of the first time. The input/output program 14 then activates the control programmer 1116. The control program 16 sequentially extracts the start addresses of pattern data one by one from the pattern data table 20 and passes them to the pattern matching program. Pattern data 2
J- is previously converted into a network type representation and stored in the pattern data area 19. (The next node address has also been set.) The pattern matching program 17 combines the human data 22 and the control program 16.
A matching process is performed with one of the pattern data 21 ' designated by .

第9図にパターンマツチングプログラムの処理の流れを
示す。
FIG. 9 shows the processing flow of the pattern matching program.

初期設定24では、処理用のポインタT’+’lにそれ
ぞれ入力データの先頭セルアドレス、パターンデータの
先頭セルアドレスを設定する。
In the initial setting 24, the starting cell address of the input data and the starting cell address of the pattern data are respectively set in the processing pointer T'+'l.

ポインタPの指すセル(セルTJ)とポインタqの指す
セル(セルq)の一致判定処理26でセルの内容が一致
し丸なら、入力データ、パターンデータのそれぞれのノ
ード探索処理28.30を行なう。入力データ、パター
ンデータ共に静的に次ノードアドレス設定済のネットワ
ーク型表現であるから、ノード探索はポインタを1つ先
のセルへ進め、そのセルの種別がポインタセルならばそ
のポイント先を次のセルとすればよい。
If the cell contents pointed to by the pointer P (cell TJ) and the cell pointed to by the pointer q (cell q) match in the match determination process 26 and are circles, then node search processes 28 and 30 are performed for each of the input data and pattern data. . Since both input data and pattern data are network type expressions with the next node address statically set, node search advances the pointer to the next cell, and if the cell type is a pointer cell, the point destination is moved to the next cell. It may be a cell.

終了判定32にて探累後のセルが終端セルでなければ処
理26へ戻る。
If the cell after the search is not the terminal cell in end determination 32, the process returns to process 26.

第10図は、prolog言語処理系における実施例の
ブロック構成図である。
FIG. 10 is a block diagram of an embodiment of the prolog language processing system.

計算機34は、ディスク装置36上に格納されているプ
ログラム38を読み込み、キーボード40から入力され
る質問人力42に対して解44をCRTデイスプレィ装
置46に出力する。
The computer 34 reads a program 38 stored on a disk device 36 and outputs an answer 44 to a CRT display device 46 in response to a question 42 input from a keyboard 40.

プログラム38は任意の個数の事実文と規則文から構成
される。ここでは、説明の簡貼化のために事実文だけ構
成されると仮定する。第10図には2つの事実文48.
50が示されている。
The program 38 is composed of an arbitrary number of factual sentences and rule sentences. Here, in order to simplify the explanation, it is assumed that only factual sentences are constructed. Figure 10 shows two factual sentences 48.
50 is shown.

質問入力には、木構造データおよびそのデータに対する
操作指示が記述できる。質問人力52は、f(g(z、
z)、x)とパターンマツチングする事実文が存在する
か否かの質問である。ここで2゜Xは変数を表わす。シ
ステムは、事実文48゜50と順次パターンマツチング
を行ない、事実文50とパターンマツチング可能でかつ
その時「2=a、X−不定」であることを解54として
出力する。
In the question input, tree structure data and operation instructions for the data can be described. The question human power 52 is f(g(z,
The question is whether there is a factual sentence that pattern matches z) and x). Here, 2°X represents a variable. The system sequentially performs pattern matching with the factual sentence 48.degree. 50, and outputs as a solution 54 that pattern matching is possible with the factual sentence 50 and that "2=a,X-indeterminate" at that time.

次の質問入力56は、変数yに木構造データf(g(z
、zL  x)を代入しくy=f(g(z、z)。
The next question input 56 inputs tree structure data f(g(z
, zL x) and y=f(g(z, z).

x)+変数yとパターンマツチングする事実文を探しく
ca Q Q (y ))、変数yを変数Xに代入しく
X=y)、もし変数yの値がループを含まないから変数
yの値を事実文としてプログラムに追加する(asse
nt(y ))ことを指示している。システムはass
ert(y )の時点で変数yの値がループを含む木構
造データであることを検出し、実行不可能(n&)を解
58として出力する。
x) + variable y to find a factual statement that pattern matches ca Q Q (y )), assign variable y to variable Add a value to the program as a fact statement (asse
nt(y)). The system is ass.
At the time of ert(y), it is detected that the value of the variable y is tree-structured data including a loop, and an unfeasible (n&) is output as the solution 58.

第11図は、第」、0図の実施例における計算機34で
実行されるソフトウェア構成を示すものである。ソフト
ウェアは、制御プロゲラ!160、読込処理プログラム
62、推論プログラム64とプログラムエリア66、デ
ータエリア68から構成される。図中の破線矢印は制御
の流れを、実線矢印はデータの流れを示す。
FIG. 11 shows the software configuration executed by the computer 34 in the embodiment shown in FIG. Software controls ProGuerra! 160, a reading processing program 62, an inference program 64, a program area 66, and a data area 68. The dashed arrows in the figure indicate the flow of control, and the solid arrows indicate the flow of data.

第11図を用いて実施例システムの動作の概要を説明す
る。制御プログラム60は、キーボード40から入力さ
れる質問入力に応じて読込処理ブログラム62あるいは
推論プログラム64を起動する。読込処理プロゲラ11
62を起動するのは、質問入力として“?−プログラム
読み込み″が入力された場合である。読込処理プログラ
ム62は、ディスク装置36内のプログラム38を読み
、プログラムエリア66にネットワーク型表現で格納す
る。プロゲラ11の木構%11にはループは存在しない
ので、このネットワーク型表現における次ノードアドレ
ス部分は静的に設定しておく。
An overview of the operation of the embodiment system will be explained using FIG. 11. The control program 60 starts a reading processing program 62 or an inference program 64 in response to a question input from the keyboard 40. Loading processing progera 11
62 is activated when "?--Read program" is input as a question input. The read processing program 62 reads the program 38 in the disk device 36 and stores it in the program area 66 in network type representation. Since there is no loop in the tree structure %11 of the progera 11, the next node address part in this network type representation is set statically.

上記以外の質問人力が入力されると、制御プログラム6
0は、データエリアに入力内容を格納すると共に推論プ
ログラム64を起動する。推論プログラム64には中4
−化処理641、操作処理643、虹新処理645があ
り、それぞれプログラムとデータのパターンマツチング
、データの変更、ブロクラムの更新の処理を行なう。
If a question other than the above is input, the control program 6
0 stores the input contents in the data area and starts the inference program 64. Reasoning program 64 has 4th grade
- conversion processing 641, operation processing 643, and rainbow update processing 645, each of which performs pattern matching of programs and data, data changes, and block diagram update processing.

データエリア内に格納されるデータも、ネットワーク型
表現であるが、その中の次ノードアドレスはあらかじめ
設定しない。
The data stored in the data area is also a network type representation, but the next node address therein is not set in advance.

第12図にプログラムエリア66、データエリ768の
詳細な閘成因を示す。図は、第10図におけるプログラ
ム38を読み込み、質問入力56と読み込んだ時点での
状態を示している。
FIG. 12 shows the detailed causes of the program area 66 and data area 768. The figure shows the state at the time when the program 38 in FIG. 10 is read and the question input 56 is read.

プログラムエリアにはネットワーク型表現されたプログ
ラム661,662とそれらの格納位[と管理するプロ
グラムテーブル667およびブ[1グラ11チエイン6
65が格納されている。
The program area includes programs 661 and 662 expressed in network format, their storage locations [and a program table 667 to manage them], and a program table 667 and a block [1 program 11 chain 6
65 is stored.

データエリア68は、後述のC11−化処理で使用する
スタック領域681とデータを格納するヒープ領域68
3から構成される。ヒープ領域683には、質問文内に
存在するデータ、あるいは処理実行中に生成されるデー
タがネットワーク型表現で格納される。hだし、各表現
内容の次ノードアドレスをあらかじめ静的に設定するこ
とはしない。
The data area 68 includes a stack area 681 used in C11 conversion processing described later and a heap area 68 for storing data.
Consists of 3. In the heap area 683, data existing in the question text or data generated during processing is stored in a network type representation. However, the next node address of each expression content is not statically set in advance.

(図中斜線部分)データには、共用部分を持つ表現、あ
るいはループを含む表現が要求される場合があるからで
ある。
(Shaded area in the figure) This is because data may require an expression that has a shared part or an expression that includes a loop.

第13図に推論プロゲラ1164内の中−化処理641
の処理の流れを示す。前述の実施例におけるパターンマ
ツチング処理(第9り1)との主な相違は、セルqのた
めのノード探索処理73の部分である。ここでセルpは
プログラムエリア66内のデータを指し、セルqはデー
タエリア68内のデータを指す。セルpの指すデータも
、セルqの指すデータも共にネットワーク型表現である
が、前者の次ノードアドレスはあらかじめ設定されてい
るのに対し後者の次ノードアドレスは設定されていない
。そこで、ここでは後者のデータのノード探索は、トリ
ー型表現されていると見なし、従来通リスタックへのア
ドレス退避(puch)と回轟(pop)処理を用いて
実施している。他の方法としてpush、 popを行
なわず、後述の更新処理と同様に、各ノードの次ノード
アドレスの動的な設定によりノード探索を行なうことも
できる。
FIG. 13 shows neutralization processing 641 in the inference progera 1164.
The flow of processing is shown below. The main difference from the pattern matching process (No. 9, Part 1) in the previous embodiment is the node search process 73 for cell q. Here, cell p refers to data in program area 66, and cell q refers to data in data area 68. Both the data pointed to by cell p and the data pointed to by cell q are network type expressions, but the next node address of the former is set in advance, whereas the next node address of the latter is not set. Therefore, here, the latter node search for data is assumed to be expressed in a tree format, and is performed using the conventional address saving (puch) and repopulation (pop) processing to the restack. As another method, it is also possible to search for nodes by dynamically setting the next node address of each node, similar to the update process described later, without performing push or pop.

第14図は、更新処理645の流れを示す。更新処理の
役割は、データエリア内のデータをプログラムエリアに
複写することである。ただし、データエリア内のデータ
にはループが含まれている可能性がある。一方、プログ
ラムエリア内にループを持つデータを置くことは許され
ない。更新外理は複写処理と同時にループの存在を調ら
べねばならない。
FIG. 14 shows the flow of update processing 645. The role of the update process is to copy the data in the data area to the program area. However, the data in the data area may contain loops. On the other hand, it is not allowed to place data with loops in the program area. The update logic must check for the existence of a loop at the same time as copy processing.

第14図の処理は処理用のポインタとしてT】。The processing in FIG. 14 uses T] as a processing pointer.

d、Wkの3つを使用する。pはデータエリアのセルア
ドレス、dはプログラム(複写先)のセルアドレス、w
kは一時退避用の作業ポインタである。また、本例では
セルの種別として、ファクタセル(子ノードを持つノー
ドのノード値を示すセル)、アトムセル(子ノードを持
たないノードのノード値を示すセル)、ポインタセル(
他のセルのアドレスを指す)の他に、次ノードアドレス
を格納するセルであることを示すセル種別(リンクセル
)を新設し、処理のm純化を図っている。
d and Wk are used. p is the cell address of the data area, d is the cell address of the program (copy destination), w
k is a work pointer for temporary saving. In addition, in this example, the cell types are factor cells (cells that indicate the node values of nodes that have child nodes), atom cells (cells that indicate the node values of nodes that do not have child nodes), and pointer cells (cells that indicate the node values of nodes that have no child nodes).
A new cell type (link cell) indicating that the cell stores the next node address has been added to simplify processing.

初期設定75では、ブロクラムエリア66に2セル分の
エリアを確保し、dに先頭のセルアドレスを設定し、2
番目のセルには終端ノードであることを示すノード値r
endJを設定する。また、■)にはデータエリア68
内の複写対象データのアドレスを設定しておく。
In the initial setting 75, an area for two cells is secured in the block area 66, the first cell address is set in d, and
The node value r indicating that the th cell is the terminal node
Set endJ. ■) also has data area 68.
Set the address of the data to be copied within.

次にセルpの種別を判定しく76)、ポインタセルなら
ば、その次のアドレスをwkに退避した後セルpの指す
光を新らたなpの71(レスとする(77)。リンクセ
ルならば、当該ノードの探索が終了したわけであるから
、そのセルの、指すアドレスを次のセルアドレスとする
と共に、セルの値を空(たとえば値ゼロ)とする。ファ
クタセルの場合は、そのセルの最後尾にある次ノードセ
ルを判断する(79)。空でなければ、ループが発生し
ているので処理を終了する。空であれば、新らたなエリ
アをプログラムエリア66内に確保し、dの指すセルに
は新らたなエリアへのポインタを設定すると共に、新エ
リアの先頭にはセルp (ファンフタセル)の内容を複
写する(80)。また、セルpに続くセルの最後尾のセ
ルである次ノードセルには、W kに退避してあったア
ドレスを設定する(81)。セルpがア1〜ムセルなら
ば、その内容をdの指すセルに複写する。アトムセル、
ファンフタセルの処理終了後は、pとdのポインタをそ
れぞれ1−の進め(83)、終了か否かの判定(84)
の後、再度処理76からくり返す。
Next, the type of cell p is determined (76), and if it is a pointer cell, the next address is saved to wk, and the light pointed to by cell p is changed to 71 (response) of p (77). Link cell If so, the search for the node has ended, so the address pointed to by that cell is set as the next cell address, and the value of the cell is set to be empty (for example, the value is zero).In the case of a factor cell, its Determine the next node cell at the end of the cell (79). If it is not empty, a loop has occurred and the process ends. If it is empty, a new area is secured in the program area 66. , a pointer to the new area is set in the cell pointed to by d, and the contents of cell p (fan cover cell) are copied to the beginning of the new area (80). The address saved in Wk is set in the next node cell, which is the last cell (81).If cell p is A1~Mucell, its contents are copied to the cell pointed to by d.Atom cell,
After completing the processing of the fan lid cell, advance the p and d pointers by 1 (83), and determine whether or not the process has ended (84).
After that, the process is repeated again from process 76.

(:+ 0 ) 〔発明の効果〕 本発明によれば、ノード検察時に必要な次ノードアドレ
スを各ノード毎に保持するので、ループを含む可能性の
ない木構造データの場合は、ノード探索をアドレス退避
なしに高速に実施でき、ループを含む可能性のある木構
造データの場合は、ループの存在有無判断を高速に実施
できろという効果がある。
(:+0) [Effects of the Invention] According to the present invention, the next node address required when searching a node is held for each node, so in the case of tree-structured data that has no possibility of containing loops, node search can be performed. This method can be implemented at high speed without saving addresses, and in the case of tree-structured data that may include loops, it has the effect of being able to quickly determine the presence or absence of loops.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図、第6図、第7図は発明方式のデータ表現の例、
第2図、第4図は木箭造データの例、第3図は従来のデ
ータ表現の例、第5図は発明方式の概念図、第8図、第
9図は1実施例のシステム入出力関連図と処理の流れ図
、第1Q図、第11図、第12図、第13図、第14図
は別の実施例の入出力関連図、ソフトウニ、ア構成因お
よび処理の流れ図である。
Figures 1, 6, and 7 are examples of data representation using the invention method.
Figures 2 and 4 are examples of wooden bamboo construction data, Figure 3 is an example of conventional data representation, Figure 5 is a conceptual diagram of the inventive method, and Figures 8 and 9 are system inputs of one embodiment. Output related diagrams and processing flowcharts, Figures 1Q, 11, 12, 13, and 14 are input/output related diagrams, software, component factors, and processing flowcharts of other embodiments. .

Claims (1)

【特許請求の範囲】 1、木構造データのノードのノード値と、前記ノードに
属する子ノードのノード情報のメモリ上の格納位置を示
す子ノードアドレスと、該ノードの次に探索するノード
のノード情報のメモリ上の格納位置を示す次ノードアド
レスから構成されるノード情報エリアを前記木構造デー
タの前記ノード毎に設け、 与えられた木構造データを表わすノード値と子ノードア
ドレスを前記ノード情報エリアの所定位置に設定する第
1のステップと、 前記木構造データの探索順序を決定し次ノードアドレス
を前記ノード情報エリアの所定位置に設定する第2のス
テップと、子ノードアドレスが設定されていない場合に 前記次ノードアドレスを用いて前記n進木構造データの
各ノード情報を順次参照する第3のステップと からなることを特徴とする木構造データのノード探索方
法。 2、ノード情報として、ゼロ以上m個の子ノードを持つ
ノードに対応してm+2個のセルの並びからなるノード
情報エリアを設けることを特徴とする特許請求の範囲第
1項記載の木構造データのノード探索方法。 3、ノード情報を表わすセルの種別として、子ノードを
持つノードのノード値を表わすフ アンクタセルと子ノードを持たないノードのノード値を
表わすセルアトムセルを設け、子ノードを持たないノー
ドのノード情報は1個のアトムセルで表現し、子ノード
を持たないノードを子ノードとして持つノード情報にお
いては、子ノードアドレスを示すアドレスセルの代わり
に子ノードの値を示すアトムセルを用いることを特徴と
する第1項記載の木構造データのノード探索方法。 4、特許請求の範囲第1項記載木構造データのノード探
索方法において、第2のステップと第3のステップをノ
ード毎に交互に実行することを特徴とする木構造データ
のノード探索方法。 5、特許請求の範囲第4項記載の木構造データのノード
探索方法において、第3のステップで、次ノードアドレ
スに従つて次ノードに至つたとき、その参照した次ノー
ドアドレスを消去し、第2のステップにおいて、次ノー
ドアドレスが設定されているか否かを判定し、次ノード
アドレスが設定されているとき木構造内の再帰的ループ
が有とすることを特徴とする木構造のデータのノード探
索方法。 6、木構造データを取り扱う記号処理言語の処理方法に
おいて、与えられた木構造データのノードのノード値と
、前記ノードに属する子ノードのノード情報のメモリ上
の格納位置を示す子ノードアドレスと、該ノードの次に
探索するノードのノード情報のメモリ上の格納位置を示
す次ノードアドレスから構成されるノード情報を格納す
るノード情報エリアを前記与えられた木構造データのノ
ード毎に設け、 前記与えられた木構造データの各ノードを表わすノード
値と子ノードアドレスを前記ノード情報エリアの所定位
置に設定する第1のステップと、 該ノードの次ノードアドレスを設定する該ノードのノー
ド情報エリアの所定位置に次ノードアドレスが設定され
ているか否かを判定する第2のステップと、 前記判定の結果、次ノードアドレスが設定されていない
場合に、前記与えられた木構造データの予め定めた探索
手順に基づいて該ノードの次ノードアドレスを該ノード
のノード情報エリアの所定位置に設定する第3のステッ
プと、該ノードのノード情報エリアに子ノードアドレス
が設定されていない場合に前記次ノードアドレスに従つ
て次ノードを探索し、該次ノードアドレスを消去する第
4のステップと、 からなり、第2から第4のステップをノード毎に繰り返
し、 第2のステップにおける前記判定の結果、次ノードアド
レスが設定されている場合に、前記与えられた木構造デ
ータ内に内部ループが存在するとし、前記内部ループに
対応するノードを他と異なる態様で表示する第5のステ
ップと、を設けたことを特徴とする木構造データのノー
ド探索方法。
[Claims] 1. A node value of a node of tree-structured data, a child node address indicating a storage location in memory of node information of a child node belonging to the node, and a node to be searched next after the node. A node information area consisting of a next node address indicating a storage location of information in memory is provided for each node of the tree structure data, and a node value representing the given tree structure data and a child node address are stored in the node information area. a first step of setting the search order of the tree structure data to a predetermined position in the node information area; a second step of determining the search order of the tree structure data and setting the next node address to a predetermined position of the node information area; a third step of sequentially referring to each node information of the n-ary tree structure data using the next node address when the next node address is used. 2. Tree-structured data according to claim 1, characterized in that node information is provided with a node information area consisting of a sequence of m+2 cells corresponding to a node having zero or more m child nodes. node search method. 3. As types of cells representing node information, funta cells representing the node values of nodes with child nodes and cell atom cells representing the node values of nodes without child nodes are provided, and node information of nodes without child nodes is one cell. In the node information that is expressed by an atom cell and has a node that does not have a child node as a child node, an atom cell that indicates the value of the child node is used instead of an address cell that indicates the child node address. A node search method for tree-structured data. 4. A method for searching for nodes in tree-structured data according to claim 1, characterized in that the second step and the third step are executed alternately for each node. 5. In the node search method for tree-structured data described in claim 4, in the third step, when the next node is reached according to the next node address, the referenced next node address is deleted and the next node address is deleted. In step 2, it is determined whether or not a next node address is set, and when the next node address is set, a recursive loop within the tree structure is determined to exist. Search method. 6. In a processing method for a symbolic processing language that handles tree-structured data, a node value of a node of given tree-structured data and a child node address indicating a storage location in memory of node information of a child node belonging to the node; A node information area is provided for each node of the given tree structure data to store node information consisting of a next node address indicating a storage location in memory of the node information of the node to be searched next to the given node; a first step of setting a node value and child node address representing each node of the tree-structured data in a predetermined position in the node information area; and setting a next node address of the node in a predetermined position in the node information area of the node. a second step of determining whether or not a next node address is set at the position; and, if the result of the determination is that the next node address is not set, a predetermined search procedure for the given tree structure data; a third step of setting the next node address of the node in a predetermined position of the node information area of the node based on the node information area of the node; Therefore, a fourth step of searching for the next node and erasing the next node address; repeating the second to fourth steps for each node, and determining the next node address as a result of the determination in the second step. is set, a fifth step of assuming that an inner loop exists in the given tree structure data and displaying a node corresponding to the inner loop in a manner different from others. A node search method for tree-structured data.
JP63306073A 1988-12-05 1988-12-05 Method for searching node of tree structure data Pending JPH02151971A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP63306073A JPH02151971A (en) 1988-12-05 1988-12-05 Method for searching node of tree structure data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP63306073A JPH02151971A (en) 1988-12-05 1988-12-05 Method for searching node of tree structure data

Publications (1)

Publication Number Publication Date
JPH02151971A true JPH02151971A (en) 1990-06-11

Family

ID=17952715

Family Applications (1)

Application Number Title Priority Date Filing Date
JP63306073A Pending JPH02151971A (en) 1988-12-05 1988-12-05 Method for searching node of tree structure data

Country Status (1)

Country Link
JP (1) JPH02151971A (en)

Similar Documents

Publication Publication Date Title
US4514826A (en) Relational algebra engine
US5438511A (en) Disjunctive unification
JPS62194533A (en) Pattern matching system for tree structure data
US5452226A (en) Rule structure for insertion of new elements in a circuit design synthesis procedure
Yahia et al. iO2 An algorithmic method for building inheritance graphs in object database design
Gibbons et al. Optimal parallel algorithms for dynamic expression evaluation and context-free recognition
EP0575066A2 (en) Error handling in a state-free system
Kowalski Directions for logic programming
JPH02151971A (en) Method for searching node of tree structure data
Munakata Procedurally oriented programming techniques in Prolog
JPH033249B2 (en)
JP2735255B2 (en) Hatching treatment method
JPH01156831A (en) Access control system for table
Jones et al. Implementation techniques for TEMPO
JPH06175862A (en) Electronic computer
JPH04160435A (en) Information storing method
Guichard-Jary PADMAVATI Parallel Associative Development Machine as a Vehicle for Artificial Intelligence
JPH033263B2 (en)
JPS63229528A (en) Knowledge base processor
JPH0577098B2 (en)
JPH0461382B2 (en)
JPS63156241A (en) Frame type knowledge management system
JPH02216533A (en) Device and method for executing rule base
JPS61170840A (en) Join processing system by partial convolution joining method
JPH0296274A (en) Information retrieving device of multiplex index structure